Skip to content

Surface reasoning tokens in exec JSON usage#19308

Merged
etraut-openai merged 1 commit intomainfrom
etraut/implement-issue-19022
Apr 24, 2026
Merged

Surface reasoning tokens in exec JSON usage#19308
etraut-openai merged 1 commit intomainfrom
etraut/implement-issue-19022

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Apr 24, 2026

Summary

Fixes #19022.

codex exec --json currently emits turn.completed.usage with input, cached input, and output token counts, but drops the reasoning-token split that Codex already receives through thread token usage updates. Programmatic consumers that rely on the JSON stream, especially ephemeral runs that do not write rollout files, need this field to accurately display reasoning-model usage.

This PR adds reasoning_output_tokens to the public exec JSON Usage payload and maps it from the existing ThreadTokenUsageUpdated total token usage data.

Verification

  • Added coverage to event_processor_with_json_output::token_usage_update_is_emitted_on_turn_completion so turn.completed.usage.reasoning_output_tokens is asserted.
  • Updated SDK expectations for run() and runStreamed() so TypeScript consumers see the new usage field.
  • Ran cargo test -p codex-exec.
  • Ran pnpm --filter ./sdk/typescript run build.
  • Ran pnpm --filter ./sdk/typescript run lint.
  • Ran pnpm --filter ./sdk/typescript exec jest --runInBand --testTimeout=30000.

@etraut-openai etraut-openai marked this pull request as ready for review April 24, 2026 07:36
@etraut-openai etraut-openai force-pushed the etraut/implement-issue-19022 branch from 7c292ae to 7dd6b74 Compare April 24, 2026 07:43
@etraut-openai etraut-openai merged commit ddfa691 into main Apr 24, 2026
25 checks passed
@etraut-openai etraut-openai deleted the etraut/implement-issue-19022 branch April 24, 2026 08:54
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Surface reasoning_output_tokens in turn.completed.usage on the --json stream

2 participants