Expose cumulative session cost in TokenCountEvent / event stream

Resolved 💬 1 comment Opened Mar 30, 2026 by simonrosenberg Closed May 31, 2026

What variant of Codex are you using?

CLI

What feature would you like to see?

Expose an authoritative cumulative session cost (e.g. cumulative_cost_usd: Option<f64>) in the event stream — ideally on TokenCountEvent or TokenUsageInfo.

Why

The OpenAI Responses API returns token counts but no cost or pricing information. Downstream consumers (ACP adapters, telemetry tools, benchmark harnesses) cannot compute cost themselves because:

  1. Service tier matters/fast mode pricing differs significantly from standard, and the tier isn't exposed in session logs either (see #13794)
  2. Auth method matters — ChatGPT subscription vs API-key billing have different cost structures
  3. Model pricing changes — hardcoding a pricing table in every consumer is brittle and will drift

Codex is the only component in the stack that knows all three variables (model, service tier, auth/billing method), making it the right place to compute and expose cost.

Concrete impact

  • codex-acp: The ACP protocol defines UsageUpdate.cost for cumulative session cost. codex-acp has the plumbing ready but cannot populate it because there is no upstream cost signal (see zed-industries/codex-acp#209)
  • ccusage and similar tools: Currently parse session logs for token counts but cannot determine actual cost without service tier info (#13794)
  • Benchmark/eval harnesses: Cannot compare spend across ACP and non-ACP agents when cost is missing

For comparison, the Claude Agent SDK already exposes total_cost_usd on result messages, which allows claude-agent-acp to populate UsageUpdate.cost today.

Suggested shape

Add a field to TokenUsageInfo or emit a new event:

// Option A: extend TokenUsageInfo
pub struct TokenUsageInfo {
    pub total_token_usage: TokenUsage,
    pub last_token_usage: TokenUsage,
    pub model_context_window: Option<i64>,
    pub cumulative_cost_usd: Option<f64>,  // NEW
}

// Option B: new field on TokenCountEvent
pub struct TokenCountEvent {
    pub info: Option<TokenUsageInfo>,
    pub rate_limits: Option<RateLimitSnapshot>,
    pub cumulative_cost_usd: Option<f64>,  // NEW
}

Are you interested in implementing this feature?

Happy to help with the downstream integration in codex-acp once the signal is available.

Additional information

Related issues:

  • #13794 — service tier not in session logs, preventing cost computation
  • #3847 — cost visibility for enterprise logins (closed without resolution)
  • zed-industries/codex-acp#209UsageUpdate.cost always null

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗