Preserve context annotations in merged messages (#40184)

## What changed

- Carry each contextual fragment's `ContentItemKind` through initial context assembly and world-state updates.
- Attach the classifications to merged response messages through `content_item_kinds`, preserving their order alongside the message content.
- Convert extension prompt fragments into annotated developer fragments and classify built-in developer and guardian instructions.

## Testing

- Add an integration test covering roles and content annotations in the first request.
- Update world-state and persisted-history tests to account for annotation metadata.

GitOrigin-RevId: 71c48dad5b17bffd47ba03263e3eb6d5e74fbf4b
This commit is contained in:
pakrym-oai authored and copyberry committed 2026-08-23 04:41:11 +00:00
1 parent 422239eb4b
commit c4b434aae2
8 files changed
+199 -76

No files matched your search

@@ -1,5 +1,7 @@
// All this file should be replaced by the existing fragment implementation ofc
use codex_context_fragments::AnnotatedContent;
use codex_context_fragments::RenderedFragment;
use codex_protocol::models::ContentItemKind;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
@@ -50,3 +52,12 @@ impl PromptFragment {
&self.content_kind
}
}
impl From<PromptFragment> for RenderedFragment {
fn from(fragment: PromptFragment) -> Self {
Self::new(
"developer",
AnnotatedContent::input_text(fragment.text, fragment.content_kind),
)
}
}