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

+4 -4
View File
@@ -4,6 +4,7 @@ use crate::agent::role::apply_role_to_config;
use crate::config::PermissionProfileSnapshot;
use crate::context::ContextualUserFragment;
use crate::context::CurrentTimeReminder;
use crate::context::DeveloperInstructions;
use crate::context::ManagedDeveloperInstructions;
use crate::context::MultiAgentModeInstructions;
use crate::context::MultiAgentRoleInstructions;
@@ -845,11 +846,10 @@ impl AgentControl {
.reference_context_item()
.await
.is_some()
&& let Some(developer_message) =
crate::context_manager::updates::build_developer_update_item(vec![
subagent_developer_instructions.clone(),
])
{
let developer_message = ContextualUserFragment::into(DeveloperInstructions::new(
subagent_developer_instructions,
));
forked_rollout_items.push(RolloutItem::ResponseItem(developer_message.into()));
}
if preserve_reference_context_item