Preserve developer instruction annotations in subagent forks (#40297)

## What changed

- Add a dedicated contextual fragment for developer instructions that emits the
  `generic.developer_instructions` content kind.
- Use the fragment when adding child-specific developer instructions to a
  full-history subagent fork, preserving their classification and ensuring they
  reach the child exactly once without appearing in the parent request.

## Testing

- Extend full-history subagent coverage to verify the child-only instructions'
  annotation, placement, and count.

GitOrigin-RevId: 82589d311535225fed76d500a19458fda72f40f2
This commit is contained in:
pakrym-oai authored and copyberry committed 2026-08-23 23:56:23 +00:00
1 parent 84c989acf9
commit a70974c1a0
7 files changed
+72 -32

No files matched your search

+3 -7
View File
@@ -21,6 +21,7 @@ use crate::compact::CompactedHistoryMetadata;
use crate::config::ManagedFeatures;
use crate::config::resolve_tool_suggest_config_from_layer_stack;
use crate::context::ContextualUserFragment;
use crate::context::DeveloperInstructions;
use crate::context::ManagedDeveloperInstructions;
use crate::context::ModelSwitchInstructions;
use crate::context::MultiAgentRoleInstructions;
@@ -3544,13 +3545,8 @@ impl Session {
&& let Some(developer_instructions) = turn_context.developer_instructions.as_deref()
&& !developer_instructions.is_empty()
{
developer_sections.push(RenderedFragment::new(
"developer",
AnnotatedContent::input_text(
developer_instructions,
ContentItemKind("generic.developer_instructions".to_string()),
),
));
developer_sections
.push(DeveloperInstructions::new(developer_instructions).render_fragment());
}
let loaded_plugins = self
.services