Add opt-in item-boundary interrupts for subagents (#61909)

## What changed

Add the multi-agent v2 setting `interrupt_at_item_boundary`, disabled by default. When enabled, `interrupt_agent` lets a subagent finish and retain its current output item while cancelling tools immediately. Later output items are discarded, and retained tool calls that have not run receive an aborted result.

Wait for the interrupted turn's terminal event before starting follow-up input, and prevent idle contributors from restarting the interrupted child.

## Testing

Add streaming tests for retaining an assistant message or tool call, discarding later output, and preserving history and follow-up input when the child resumes. Update configuration and interrupt-routing tests.

GitOrigin-RevId: 8b2b9b1383bfb4eefea7369a40012bebc5fff07b
This commit is contained in:
jif
2026-11-16 23:26:07 +00:00
committed by copyberry
parent 837f8b50be
commit cff061fca9
20 changed files with 475 additions and 47 deletions
@@ -3950,14 +3950,14 @@ async fn multi_agent_v2_interrupt_agent_accepts_task_name_target() {
let ops = manager.captured_ops();
assert!(
ops.iter()
.any(|(thread_id, op)| *thread_id == agent_id && matches!(op, Op::Interrupt))
.any(|(thread_id, op)| *thread_id == agent_id && matches!(op, Op::InterruptAgent))
);
assert!(!ops.iter().any(|(thread_id, op)| {
(*thread_id == agent_id || *thread_id == child_id) && matches!(op, Op::Shutdown)
}));
assert!(
!ops.iter()
.any(|(thread_id, op)| *thread_id == child_id && matches!(op, Op::Interrupt))
.any(|(thread_id, op)| *thread_id == child_id && matches!(op, Op::InterruptAgent))
);
}