Skip to content

fix(codex): retain reported reasoning token usage - #306

Merged
mikamikasuki merged 1 commit into
mikamikasuki:mainfrom
Ehsan-hash:fix/codex-reasoning-usage
Oct 16, 2026
Merged

mikamikasuki merged 1 commit into
mikamikasuki:mainfrom
Ehsan-hash:fix/codex-reasoning-usage

Conversation

@Ehsan-hash

Copy link
Copy Markdown
Contributor

Codex CLI reports reasoning_output_tokens, but the transport discards it before saving request usage. Agent accounting therefore shows zero reasoning tokens even when the CLI reports a measured count. This maps the reported counter to the existing canonical reasoning_tokens field.

Closes #86.

Input, cached input and total output counts stay unchanged. Missing reasoning usage remains unknown in the normalized request, an explicit zero is preserved, and subscription cost remains unpriced. No shared accounting, pricing, schema or frontend change is needed.

Validation:

  • All three new cases fail on the original source and pass after the change, covering reported, zero and missing reasoning counts in returned usage and the request event.
  • The focused provider/provenance and non-execution recovery checks pass, 25 tests. The CLI-budget API scenario also passes.
  • A real temporary fixture executable runs through the actual transport, ModelClient and SQLite request ledger. Its reported 42 reasoning tokens survive the saved request and Agent accounting. Input stays 100, cached input 20 and total output 50; completed status and unknown cost are preserved. The same integration fails on the original source.

The broader execution and worker suites have nine failing cases on this Mac. All nine also reproduce on the unchanged baseline, including missing Linux Bubblewrap support and worker-handoff failures. Full Linux execution and real Codex inference were not exercised. The CLI fixture follows the current official producer's usage schema and JSONL mapping.

Developed with OpenAI Codex assistance, automated checks and independent code review.

@mikamikasuki
mikamikasuki merged commit a76120b into mikamikasuki:main Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex CLI usage drops reported reasoning output tokens

2 participants