Conversation
This was referenced Jun 23, 2026
bolinfest
force-pushed
the
pr29665
branch
4 times, most recently
from
June 23, 2026 20:09
236e978 to
faae6d9
Compare
bolinfest
marked this pull request as ready for review
June 23, 2026 20:10
bolinfest
force-pushed
the
pr29665
branch
3 times, most recently
from
June 23, 2026 20:45
17c471a to
2bf1461
Compare
pakrym-oai
approved these changes
Jun 23, 2026
pakrym-oai
left a comment
Contributor
There was a problem hiding this comment.
Stamping to unlbock but I think token_budget::maybe_record should also be using tokens before compaction.
bolinfest
force-pushed
the
pr29665
branch
3 times, most recently
from
June 23, 2026 22:44
fdd29fc to
f2d56c6
Compare
pakrym-oai
reviewed
Jun 23, 2026
| (Some(scope_remaining), None) => Some(scope_remaining), | ||
| (None, Some(full_remaining)) => Some(full_remaining), | ||
| (None, None) => None, | ||
| }; |
Contributor
There was a problem hiding this comment.
let tokens_until_compaction = match (auto_compact_scope_remaining, full_context_remaining) {
(Some(a), Some(b)) => Some(a.min(b)),
(a, b) => a.or(b),
};
pakrym-oai
approved these changes
Jun 23, 2026
bolinfest
added a commit
that referenced
this pull request
Jun 23, 2026
## Why This PR keeps the mechanical helper extraction separate from the behavior change in #29665. The follow-up needs the token-window accounting from `turn.rs` in another call path, but reviewing that is much easier when the helper extraction is separate from the semantic change. ## What - Adds `session/context_window.rs` with `ContextWindowTokenStatus`. - Moves the existing auto-compaction token-status calculation out of `session/turn.rs`. - Replaces the duplicated inline remaining-token calculation in `turn.rs` with `tokens_until_compaction()`. This PR is intended to be behavior-preserving. The `get_context_remaining` behavior change is stacked separately in #29665. ## Testing - `just test -p codex-core auto_compact_body_after_prefix` --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/29664). * #29665 * __->__ #29664
bolinfest
force-pushed
the
pr29665
branch
2 times, most recently
from
June 23, 2026 22:51
7c14c89 to
4ba46e7
Compare
bolinfest
enabled auto-merge (squash)
June 23, 2026 23:05
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.
Why
With
model_auto_compact_token_limit_scope = "body_after_prefix", the persistent prefix should not count against the active body window.get_context_remainingand the token-budget reminder should report the same usable body-after-prefix window that auto-compaction uses, rather than the total token count since the session began.This is stacked on #29664 so the mechanical move from
turn.rsis isolated from the behavior fix.What
ContextWindowTokenStatuswithcontext_remaining_tokens.get_context_remainingto use the shared context-window accounting.get_context_remainingoutput.Testing
just test -p codex-core body_after_prefix_windowjust test -p codex-core auto_compact_body_after_prefixjust fix -p codex-core