{"record":{"id":"0e92895035521aa7","repo":"Hmbown/CodeWhale","slug":"refusing-to-interrupt-root-agents-interrupt-fails","errorCode":null,"errorMessage":"Refusing to interrupt root. agents/interrupt fails closed on the root session.","messagePattern":"Refusing to interrupt root\\. agents/interrupt fails closed on the root session\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":6364,"sourceCode":"            assignment,\n            allowed_tools,\n            options,\n            // Checkpoint resume replays under the write lock; the baseline\n            // captures inline there, as before (#6210).\n            None,\n        )?;\n        Ok(resumed)\n    }\n\n    /// Interrupt a child, preserve checkpoint, fail closed on root/self.\n    pub fn interrupt_child(\n        &mut self,\n        agent_ref: &str,\n        caller_agent_id: Option<&str>,\n        reason: String,\n    ) -> Result<(SubAgentResult, SubAgentResult)> {\n        if agent_ref.trim().eq_ignore_ascii_case(\"root\") {\n            return Err(anyhow!(\n                \"Refusing to interrupt root. agents/interrupt fails closed on the root session.\"\n            ));\n        }\n        let agent_id = self.resolve_agent_ref(agent_ref)?;\n        self.ensure_caller_controls_descendant(&agent_id, caller_agent_id, \"agents/interrupt\")?;\n\n        let prior = self.get_result_by_ref(&agent_id)?;\n        if prior.status != SubAgentStatus::Running\n            || self\n                .agents\n                .get(&agent_id)\n                .is_some_and(|agent| agent.completion_claimed)\n        {\n            return Ok((prior.clone(), prior));\n        }\n\n        // Build a continuable checkpoint from the latest stored checkpoint or a\n        // minimal placeholder so interrupt never drops recoverability silently.","sourceCodeStart":6346,"sourceCodeEnd":6382,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/mod.rs#L6346-L6382","documentation":"The agents/interrupt tool deliberately refuses to interrupt the root session. Interrupting root would kill the caller's own turn loop, so the tool fails closed when the agent reference resolves to \"root\" (case-insensitive).","triggerScenarios":"Calling agents/interrupt with `agent_ref` equal to \"root\" (any casing/whitespace) — the guard fires before resolving the ref or checking caller control.","commonSituations":"A model or script generically targeting \"root\" as the top-level agent; automations that iterate agent refs including the root; users trying to stop the whole session with the sub-agent tool instead of the session-level cancel.","solutions":["Use the session-level cancel/escape mechanism to stop the root turn, not agents/interrupt.","Target a concrete child agent id or resolvable sub-agent ref instead of \"root\".","If an automation builds agent refs, filter out the \"root\" entry before calling interrupt."],"exampleFix":"// before\nagents.interrupt(\"root\", caller, reason)?;\n\n// after\nif !agent_ref.trim().eq_ignore_ascii_case(\"root\") {\n    agents.interrupt(agent_ref, caller, reason)?;\n} else {\n    session.cancel_current_turn(); // root is stopped at session level\n}","handlingStrategy":"validation","validationCode":"fn is_root_ref(agent_ref: &str) -> bool {\n    agent_ref.trim().eq_ignore_ascii_case(\"root\")\n}\n// if is_root_ref(r) { use session_cancel(); } else { agents.interrupt(r, ...)?; }","typeGuard":null,"tryCatchPattern":"match agents.interrupt(\"root\", caller, reason) {\n    Err(e) if e.to_string().contains(\"Refusing to interrupt root\") => session.cancel_current_turn(),\n    other => other?,\n}","preventionTips":["Never pass \"root\" to agents/interrupt; use the session-level cancel control","Filter the root entry out of any automated agent-ref iteration","Target concrete child agent ids"],"tags":["subagent","interrupt","guard","invalid-argument"],"backgroundTag":"unsupported-operation","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}