Preserve turn triggers across delegated agent work (#44659)

## Why

Delegated usage should retain the trigger of the turn that initiated it, including composer input and scheduled automation.

## What changed

Propagate `turn_trigger` through agent spawning and follow-up messages in both multi-agent tool implementations. Apply the supplied trigger when pending mailbox work starts a new turn.

## Testing

Extend tests to verify trigger propagation to spawned and nested agents, updated triggers on reused agents and peer follow-ups, and preservation of the active turn's trigger when steering.

GitOrigin-RevId: e8fea208587c633fec7cb3f1c0815ff91d1a44e5
This commit is contained in:
joeytrasatti-openai
2026-09-10 22:26:26 +00:00
committed by copyberry
parent 4caa5d615d
commit e004dc6a4b
10 changed files with 85 additions and 7 deletions
@@ -93,6 +93,7 @@ impl Handler {
crate::TurnStartOptions {
parent_turn_id: Some(turn.sub_id.clone()),
root_turn_id: turn.turn_metadata_state.root_turn_id(),
turn_trigger: turn.turn_metadata_state.current_turn_trigger(),
cyber_access_program: turn.cyber_access_program,
..Default::default()
},
@@ -124,6 +124,7 @@ async fn handle_spawn_agent(
parent_thread_id: Some(session.thread_id),
parent_turn_id: Some(turn.sub_id.clone()),
root_turn_id: turn.turn_metadata_state.root_turn_id(),
turn_trigger: turn.turn_metadata_state.current_turn_trigger(),
environments: Some(step_context.environments.to_selections()),
multi_agent_v2_usage_hints: None,
cyber_access_program: turn.cyber_access_program,
@@ -120,6 +120,7 @@ pub(super) async fn handle_message_string_tool(
crate::TurnStartOptions {
parent_turn_id,
root_turn_id: turn.turn_metadata_state.root_turn_id(),
turn_trigger: turn.turn_metadata_state.current_turn_trigger(),
cyber_access_program: turn.cyber_access_program,
..Default::default()
},
@@ -219,6 +219,7 @@ async fn handle_spawn_agent(
parent_thread_id: Some(session.thread_id),
parent_turn_id: Some(turn.sub_id.clone()),
root_turn_id: turn.turn_metadata_state.root_turn_id(),
turn_trigger: turn.turn_metadata_state.current_turn_trigger(),
environments: Some(step_context.environments.to_selections()),
multi_agent_v2_usage_hints,
cyber_access_program: turn.cyber_access_program,