feat: make interrupt state not final for multi-agents (#13850)

Make `interrupted` an agent state and make it not final. As a result, a
`wait` won't return on an interrupted agent and no notification will be
send to the parent agent.

The rationals are:
* If a user interrupt a sub-agent for any reason, you don't want the
parent agent to instantaneously ask the sub-agent to restart
* If a parent agent interrupt a sub-agent, no need to add a noisy
notification in the parent agen
This commit is contained in:
jif-oai
2026-03-16 16:39:40 +00:00
committed by GitHub
parent 18ad67549c
commit 3f266bcd68
29 changed files with 151 additions and 4 deletions

View File

@@ -537,10 +537,13 @@ fn status_summary_line(status: &AgentStatus) -> Line<'static> {
status_summary_spans(status).into()
}
// Allow `.yellow()`
#[allow(clippy::disallowed_methods)]
fn status_summary_spans(status: &AgentStatus) -> Vec<Span<'static>> {
match status {
AgentStatus::PendingInit => vec![Span::from("Pending init").cyan()],
AgentStatus::Running => vec![Span::from("Running").cyan().bold()],
AgentStatus::Interrupted => vec![Span::from("Interrupted").yellow()],
AgentStatus::Completed(message) => {
let mut spans = vec![Span::from("Completed").green()];
if let Some(message) = message.as_ref() {
@@ -762,6 +765,25 @@ mod tests {
assert_eq!(title.spans[6].style.fg, Some(Color::Magenta));
}
#[test]
fn collab_resume_interrupted_snapshot() {
let sender_thread_id = ThreadId::from_string("00000000-0000-0000-0000-000000000001")
.expect("valid sender thread id");
let robie_id = ThreadId::from_string("00000000-0000-0000-0000-000000000002")
.expect("valid robie thread id");
let cell = resume_end(CollabResumeEndEvent {
call_id: "call-resume".to_string(),
sender_thread_id,
receiver_thread_id: robie_id,
receiver_agent_nickname: Some("Robie".to_string()),
receiver_agent_role: Some("explorer".to_string()),
status: AgentStatus::Interrupted,
});
assert_snapshot!("collab_resume_interrupted", cell_to_text(&cell));
}
fn cell_to_text(cell: &PlainHistoryCell) -> String {
cell.display_lines(200)
.iter()