You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Include per-API-call token usage (last) in turn.completed JSONL events #17539
When using codex exec, the turn.completed JSONL event reports cumulative session token totals. This makes it impossible to determine current context window utilization ... the cumulative numbers grow across API calls and quickly exceed the context window size (e.g. 6.9M cumulative input_tokens against a 272K window).
The interactive CLI doesn't have this problem because it uses the per-request data from ThreadTokenUsage.last internally. But that field is discarded when converting to the exec JSONL output ... only .total is emitted.
Adding the most recent request's token usage to the turn.completed event would bring exec output to parity with the interactive experience for context window tracking. Something like:
The data is already available in ThreadTokenUsage.last ... it just needs to be carried through to the JSONL output in event_processor_with_jsonl_output.rs (usage_from_last_total).
Additional Information
This affects any programmatic use of codex exec that wants to display or act on context window utilization.
Not a duplicate. Those issues describe user confusion caused by the exact gap this feature request addresses ... the exec JSONL only exposes cumulative totals, making it impossible to determine per-request context window usage. Adding last_usage to turn.completed would prevent that class of confusion entirely.
Activity
github-actions commentedon Apr 12, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
aroytman commentedon Apr 12, 2026
Not a duplicate. Those issues describe user confusion caused by the exact gap this feature request addresses ... the exec JSONL only exposes cumulative totals, making it impossible to determine per-request context window usage. Adding last_usage to turn.completed would prevent that class of confusion entirely.
fix(codex): emit per-turn usage delta instead of cumulative thread to…
fix(codex): capture tokens, model, and non-empty output.md on Codex 0…
Fix Codex cumulative-as-delta usage and add subtractUsage helper (#6)
fix(codex): compute cost from token deltas, not nonexistent cost_usd
etraut-openai commentedon May 16, 2026
This feature hasn't received enough upvotes, so closing.
Review fixes: per-turn codex usage, one cached-token convention, cost…
tokenlog: pin codex turn.completed usage as cumulative, not per-turn
tokenlog: pin codex turn.completed usage as cumulative, not per-turn (#…