refactor: extract context window token status (#29664)

## 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
This commit is contained in:
Michael Bolin
2026-06-23 15:49:30 -07:00
committed by GitHub
Unverified
parent 829f5b6b59
commit 4dde907d27
3 changed files with 86 additions and 76 deletions
+1
View File
@@ -211,6 +211,7 @@ use codex_protocol::exec_output::StreamOutput;
mod code_mode_warning;
mod config_lock;
pub(crate) mod context_window;
mod handlers;
mod inject;
mod input_queue;