Show token usage breakdown at the end of codex exec

Open 💬 1 comment Opened Jun 20, 2026 by vjain419

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

  1. Run codex exec "Reply with one sentence.".
  2. Wait for completion.
  3. Observe that the final token summary contains only one number.
  4. Compare with interactive Codex or the turn.completed.usage event from codex 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

  • #28083 requests the same breakdown for /goal completion, which uses a different output path.
  • #16037 requests machine-readable /status output; codex exec --json already provides these fields.
  • #20311 requests service-tier metadata in JSONL logs, not human-readable completion output.

View original on GitHub ↗

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