mirror of
https://github.com/openai/codex.git
synced 2026-09-17 12:23:33 +00:00
## Why Remote compaction can process large histories. Repeatedly estimating and replacing the full history, and cloning it when tracing is disabled, adds avoidable CPU and memory overhead. ## What changed - Estimate each history item's token count once, update the total as trailing tool outputs are rewritten, and replace history only after all rewrites are selected. - Preserve unclamped token totals while calculating removed tokens so saturated estimates do not hide overflow. - Snapshot compaction input history only when rollout tracing is enabled. - Reuse the v2 request input instead of cloning it before adding the compaction trigger. ## Testing - Cover enabled and disabled compaction trace contexts through `is_enabled()` assertions. GitOrigin-RevId: 8de9c9704ba29532fba05430eb204bbae2e8bf83
9 lines
249 B
Rust
9 lines
249 B
Rust
mod history;
|
|
mod normalize;
|
|
pub(crate) mod updates;
|
|
|
|
pub(crate) use history::ContextManager;
|
|
pub(crate) use history::estimate_item_token_count;
|
|
pub(crate) use history::is_user_turn_boundary;
|
|
pub(crate) use history::truncate_function_output_payload;
|