Classify internal model context by source (#40294)

## What changed

- Derive each `InternalModelContextFragment` content kind from its source as
  `<source>.internal_context` instead of using a shared generic kind.
- Cover the source-specific kind in the contextual user fragment test.

GitOrigin-RevId: 2075d558265fc1ae1ce394e9a865210d1bc270af
This commit is contained in:
pakrym-oai
2026-08-23 23:33:02 +00:00
committed by copyberry
parent ad32eba832
commit 9228a3a407
2 changed files with 9 additions and 4 deletions
@@ -5,6 +5,7 @@ use crate::context::InternalModelContextFragment;
use crate::context::SubagentNotification;
use codex_protocol::items::HookPromptFragment;
use codex_protocol::items::build_hook_prompt_message;
use codex_protocol::models::ContentItemKind;
use codex_protocol::models::ResponseItem;
use pretty_assertions::assert_eq;
@@ -72,12 +73,16 @@ fn detects_subagent_notification_fragment_case_insensitively() {
#[test]
fn detects_internal_model_context_fragment() {
let text = InternalModelContextFragment::new(
let fragment = InternalModelContextFragment::new(
InternalContextSource::from_static("extension"),
"Internal steering.",
)
.render();
);
let text = fragment.render();
assert_eq!(
fragment.content_kind(),
ContentItemKind("extension.internal_context".to_string())
);
assert_eq!(
text,
"<codex_internal_context source=\"extension\">\nInternal steering.\n</codex_internal_context>"
@@ -78,7 +78,7 @@ impl InternalModelContextFragment {
impl ContextualUserFragment for InternalModelContextFragment {
fn content_kind(&self) -> ContentItemKind {
ContentItemKind("generic.internal_model_context".to_string())
ContentItemKind(format!("{}.internal_context", self.source.as_str()))
}
fn role(&self) -> &'static str {