mirror of
https://github.com/openai/codex.git
synced 2026-11-22 23:00:42 +00:00
Allow volatile World State sections to refresh after compaction (#58956)
## Why Host-provided context such as budget reminders can become stale while compaction runs. Replaying a captured value or retaining its comparison snapshot can prevent the next step from emitting a fresh reminder, even when the remaining budget has changed. ## What changed - Add `WorldStateSectionContribution::without_full_context()` to omit a section's fragment and comparison snapshot from initial and compacted context rebuilds while preserving ordinary step updates. - Reset comparison state after prefix compaction for sections excluded at either capture or installation, including when their messages survive in the live suffix. - Include step World State updates when building debug prompt input. ## Testing Add regression coverage for budget reminders refreshing after remote compaction within the same threshold, unchanged request prefixes within a context window, refreshes with a retained live suffix, and step reminders in debug prompts. GitOrigin-RevId: ea4456755e16c93b5d16e8c762b26a33f8571a86
This commit is contained in:
@@ -482,6 +482,7 @@ pub(crate) enum CompactedHistoryInstallation<'a> {
|
||||
prefix: CompactionPrefix,
|
||||
prefix_context: Vec<ResponseItem>,
|
||||
initial_context: Vec<ResponseItemEnvelope>,
|
||||
reset_world_state_sections: Vec<&'static str>,
|
||||
model_info: &'a ModelInfo,
|
||||
compaction_response_id: String,
|
||||
reviewer_compaction_hash: Option<String>,
|
||||
@@ -4539,6 +4540,7 @@ impl Session {
|
||||
prefix,
|
||||
prefix_context,
|
||||
initial_context,
|
||||
reset_world_state_sections,
|
||||
model_info,
|
||||
compaction_response_id,
|
||||
reviewer_compaction_hash,
|
||||
@@ -4575,6 +4577,11 @@ impl Session {
|
||||
if let Some(checkpoint) = state.history.world_state_checkpoint() {
|
||||
world_state_baseline = WorldStateSnapshot::from(&checkpoint.state);
|
||||
}
|
||||
// Volatile sections must refresh in the new window even if their
|
||||
// previous messages and comparison state survived in the suffix.
|
||||
for section_id in reset_world_state_sections {
|
||||
world_state_baseline.remove_section(section_id);
|
||||
}
|
||||
// Prefix replacement already retains all edits in the live suffix.
|
||||
let input_goal_ids = Default::default();
|
||||
let (window_number, window_ids) = state.advance_auto_compact_window();
|
||||
|
||||
Reference in New Issue
Block a user