mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
Support window prefixes for extension world-state sections (#57276)
## What changed Add `WorldStateSectionContribution::with_window_prefix()` to render extension developer fragments as separate messages before retained history when building a context window, including after compaction. Updates within an existing window still append to history. Ignore fragments with other roles for sections that opt in. ## Testing Add a unit test for prefix placement and duplicate avoidance, plus local and remote compaction scenarios covering live updates, persisted replacement history, and rejection of non-developer fragments. GitOrigin-RevId: 8621457c6eec17f1585ca8e6fa154b1bf3257330
This commit is contained in:
committed by
copyberry
parent
166aed9854
commit
d416d8a0ff
@@ -247,11 +247,20 @@ impl ErasedWorldStateSection for ExtensionWorldStateSection {
|
||||
});
|
||||
let updates = fragment
|
||||
.into_iter()
|
||||
.filter(|fragment| !self.0.is_window_prefix() || fragment.role() == "developer")
|
||||
.map(|fragment| {
|
||||
WorldStateUpdate::fragment(WorldStateContextFragment {
|
||||
let update = WorldStateUpdate::fragment(WorldStateContextFragment {
|
||||
fragment,
|
||||
content_kind: ContentItemKind(format!("{}.instructions", self.0.id())),
|
||||
})
|
||||
});
|
||||
if self.0.is_window_prefix() {
|
||||
WorldStateUpdate {
|
||||
placement: Placement::Prefix,
|
||||
..update
|
||||
}
|
||||
} else {
|
||||
update
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
(snapshot, updates)
|
||||
|
||||
Reference in New Issue
Block a user