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 authored and copyberry committed 2026-09-10 22:26:26 +00:00
1 parent 4caa5d615d
commit e004dc6a4b
10 files changed
+85 -7

No files matched your search

+16 -1
View File
@@ -858,6 +858,9 @@ async fn steer_only_requires_active_turn() {
#[tokio::test]
async fn steer_only_enforces_expected_turn_id() {
let (session, turn_context, _rx) = make_session_and_context_with_rx().await;
turn_context
.turn_metadata_state
.set_turn_trigger("composer".to_string());
session
.spawn_task(
Arc::clone(&turn_context),
@@ -904,7 +907,12 @@ async fn steer_only_enforces_expected_turn_id() {
let submission = handle(
&session,
TurnInputRequest::new(SubmittedTurnInput::ResponseItem(output)),
TurnInputRequest::new(SubmittedTurnInput::ResponseItem(output)).on_start(
TurnStartOptions {
turn_trigger: Some("automation_cron_scheduled".to_string()),
..Default::default()
},
),
TurnInputMode::StartOrSteer,
"test-submission".to_string(),
)
@@ -917,6 +925,13 @@ async fn steer_only_enforces_expected_turn_id() {
turn_id: turn_context.sub_id.clone()
}
);
assert_eq!(
turn_context
.turn_metadata_state
.current_turn_trigger()
.as_deref(),
Some("composer")
);
let turn_state = session
.input_queue
.turn_state_for_sub_id(&session.active_turn, &turn_context.sub_id)