Repository navigation
Show token usage breakdown at the end of codex exec #29272
Description
Summary
Human-readable codex exec output currently prints only one effective token count when a run finishes.
It should show the same detailed token summary as interactive Codex: effective total, non-cached input, cached input, output, and reasoning output.
User impact
A single combined number does not show whether usage came from new context, poor cache reuse, generated output, or reasoning.
Users must select --json in advance and process JSONL to obtain information already available internally.
Current behavior
A completed human-readable run ends with output similar to:
tokens used
1,234
The displayed value is the blended total: non-cached input plus output. Cached input and reasoning output are hidden.
Expected behavior
Show the detailed breakdown, for example:
Token usage: total=1,234 input=900 (+ 5,000 cached) output=334 (reasoning 120)
The exact layout may retain the existing codex exec section style, but its fields and accounting semantics should match interactive Codex.
Minimal reproduction
- Run
codex exec "Reply with one sentence.". - Wait for completion.
- Observe that the final token summary contains only one number.
- Compare with interactive Codex or the
turn.completed.usageevent fromcodex exec --json.
Notes from code/docs review
The human-output processor retains the full ThreadTokenUsage, but reduces it to blended_total() before printing.
The JSONL processor already exposes input, cached-input, output, and reasoning-output fields. The interactive CLI already formats these values into the requested summary. No protocol or backend change appears necessary.
Why this is not covered by existing issues
- /goal completion should show token usage breakdown, not only combined usage #28083 requests the same breakdown for
/goalcompletion, which uses a different output path. - Add machine-readable status output (for example: /status --json or codex status --json) #16037 requests machine-readable
/statusoutput;codex exec --jsonalready provides these fields. - Add "service_tier" to JSONL token usage logs #20311 requests service-tier metadata in JSONL logs, not human-readable completion output.
Activity
Necmttn commentedon Jun 21, 2026
The human-readable footer should include both buckets and provenance. Example fields: total charged/effective, input uncached, input cached, output, reasoning output, and
usage_source=provider_final|estimate|partial.That matters for
codex execbecause users often run it in scripts and only see the final text. If cached or reasoning tokens are hidden, people misdiagnose cache misses or model-effort changes as ordinary output growth. JSONL can stay richer, but the terminal summary should preserve the same accounting semantics.Generated with ax.