Skip to content

Avoid double-counting retained reasoning in token usage - #55991

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/06f9272cb3c259e927941f1d2a1d7096310ffb2c
Oct 21, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/06f9272cb3c259e927941f1d2a1d7096310ffb2c

Conversation

@copyberry

@copyberry copyberry Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Avoid double-counting retained reasoning in token usage

Why

Responses Lite includes retained reasoning in its reported token usage even without an X-Reasoning-Included header. Adding a separate reasoning estimate can trigger automatic compaction prematurely. Locally recomputed usage also already includes retained reasoning.

What changed

Initialize reasoning accounting from use_responses_lite before each sampling or compaction request, while allowing server events to override it. Mark locally recomputed token usage as including reasoning.

Testing

Update the compaction regression test to verify that Responses Lite usage without the header stays below an 81-token limit at 80 tokens and triggers compaction at 81 tokens.

## Why

Responses Lite includes retained reasoning in its reported token usage even without an `X-Reasoning-Included` header. Adding a separate reasoning estimate can trigger automatic compaction prematurely. Locally recomputed usage also already includes retained reasoning.

## What changed

Initialize reasoning accounting from `use_responses_lite` before each sampling or compaction request, while allowing server events to override it. Mark locally recomputed token usage as including reasoning.

## Testing

Update the compaction regression test to verify that Responses Lite usage without the header stays below an 81-token limit at 80 tokens and triggers compaction at 81 tokens.

GitOrigin-RevId: 06f9272cb3c259e927941f1d2a1d7096310ffb2c
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/06f9272cb3c259e927941f1d2a1d7096310ffb2c branch from 4679e11 to 07cc649 Compare October 21, 2026 21:23
@copyberry
copyberry Bot merged commit 07cc649 into main Oct 21, 2026
1 check failed
@github-actions

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/06f9272cb3c259e927941f1d2a1d7096310ffb2c branch October 21, 2026 21:23
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-21T21:23:20.157121Z 4679e11 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2026

This branch was previously deployed

1 inactive deployment
issue-triage — 07cc649c Deployed Oct 21, 2026 by juancarlosroca via Translate non-English issue #21773
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.

2 participants