mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Wire background compaction into the turn lifecycle (#53800)
## What changed - Launch background compaction at eligible pre-turn, mid-turn, and post-turn checkpoints when `AsyncCompaction` is enabled, capturing the current world state and client routing state. - Adopt ready results at compaction checkpoints while preserving newer messages, tool outputs, and world-state updates. Continue normally if an optional result is rejected. - Run one foreground compaction if an adopted result still exceeds the context limit. - Prevent cancelled turns from launching new background work while preserving already-running work for later reuse. ## Testing Add unit and scenario coverage for stale history and account changes, cancellation, pending-result reuse and fallback, retained tool outputs, compaction event pairing, and token usage accounting. Add a context snapshot covering a collaboration-mode change while compaction runs. GitOrigin-RevId: 04ac028d9fe2e3ea64aacaaeb351c3c776cf3940
This commit is contained in:
@@ -388,6 +388,14 @@ impl CodexThread {
|
||||
self.session.flush_rollout().await
|
||||
}
|
||||
|
||||
/// Test barrier: waits for background compaction without consuming its published result.
|
||||
/// Call after the request starts, with foreground work gated to prevent new launches.
|
||||
#[doc(hidden)]
|
||||
pub async fn wait_for_background_compaction_for_test(&self) {
|
||||
crate::session::async_compaction::wait_for_background_compaction_for_test(&self.session)
|
||||
.await;
|
||||
}
|
||||
|
||||
pub async fn submit_with_trace(
|
||||
&self,
|
||||
op: Op,
|
||||
|
||||
Reference in New Issue
Block a user