Surface reasoning tokens in exec JSON usage#19308
Merged
etraut-openai merged 1 commit intomainfrom Apr 24, 2026
Merged
Conversation
7c292ae to
7dd6b74
Compare
sayan-oai
approved these changes
Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #19022.
codex exec --jsoncurrently emitsturn.completed.usagewith 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_tokensto the public exec JSONUsagepayload and maps it from the existingThreadTokenUsageUpdatedtotal token usage data.Verification
event_processor_with_json_output::token_usage_update_is_emitted_on_turn_completionsoturn.completed.usage.reasoning_output_tokensis asserted.run()andrunStreamed()so TypeScript consumers see the new usage field.cargo test -p codex-exec.pnpm --filter ./sdk/typescript run build.pnpm --filter ./sdk/typescript run lint.pnpm --filter ./sdk/typescript exec jest --runInBand --testTimeout=30000.