mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Capture Guardian review checkpoints from live context (#46512)
## Why Committing a Guardian review snapshot currently flushes and reloads the transcript from storage, even though the completed model context is already available in memory. ## What changed - Build forkable checkpoints directly from live session state, preserving model history, retained Guardian context, world state, turn context, and token usage. - Preserve compaction window metadata and MCP resource origins in the checkpoint. - Recognize prior user turns inside compacted replacement history. ## Testing Add round-trip checkpoint tests for legacy and thread-owned Guardian context without storage, including preservation after live history is mutated. Extend the review compaction test to assert that checkpoints do not load history from storage. GitOrigin-RevId: cb2638ca93bba6ab4472de50c7e2913e1a2f25a8
This commit is contained in:
@@ -381,6 +381,12 @@ impl ContextManager {
|
||||
self.world_state_baseline = Some(snapshot);
|
||||
}
|
||||
|
||||
pub(crate) fn world_state_checkpoint(&self) -> Option<WorldStateItem> {
|
||||
self.world_state_baseline
|
||||
.clone()
|
||||
.map(|snapshot| WorldStateItem::full(snapshot.into_object()))
|
||||
}
|
||||
|
||||
pub(crate) fn set_token_usage_full(&mut self, context_window: i64) {
|
||||
match &mut self.token_info {
|
||||
Some(info) => info.fill_to_context_window(context_window),
|
||||
|
||||
Reference in New Issue
Block a user