Hmbown/CodeWhale · error

Refusing to interrupt root. agents/interrupt fails closed…

Error message

Refusing to interrupt root. agents/interrupt fails closed on the root session.

What it means

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).

Solutions

  1. Use the session-level cancel/escape mechanism to stop the root turn, not agents/interrupt.
  2. Target a concrete child agent id or resolvable sub-agent ref instead of "root".
  3. If an automation builds agent refs, filter out the "root" entry before calling interrupt.

Example fix

// before
agents.interrupt("root", caller, reason)?;

// after
if !agent_ref.trim().eq_ignore_ascii_case("root") {
    agents.interrupt(agent_ref, caller, reason)?;
} else {
    session.cancel_current_turn(); // root is stopped at session level
}
Defensive patterns

Strategy: validation

Validate before calling

fn is_root_ref(agent_ref: &str) -> bool {
    agent_ref.trim().eq_ignore_ascii_case("root")
}
// if is_root_ref(r) { use session_cancel(); } else { agents.interrupt(r, ...)?; }

Try / catch

match agents.interrupt("root", caller, reason) {
    Err(e) if e.to_string().contains("Refusing to interrupt root") => session.cancel_current_turn(),
    other => other?,
}

Prevention

When it happens

Trigger: Calling agents/interrupt with `agent_ref` equal to "root" (any casing/whitespace) — the guard fires before resolving the ref or checking caller control.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/0e92895035521aa7. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/subagent/mod.rs:6364

            assignment,
            allowed_tools,
            options,
            // Checkpoint resume replays under the write lock; the baseline
            // captures inline there, as before (#6210).
            None,
        )?;
        Ok(resumed)
    }

    /// Interrupt a child, preserve checkpoint, fail closed on root/self.
    pub fn interrupt_child(
        &mut self,
        agent_ref: &str,
        caller_agent_id: Option<&str>,
        reason: String,
    ) -> Result<(SubAgentResult, SubAgentResult)> {
        if agent_ref.trim().eq_ignore_ascii_case("root") {
            return Err(anyhow!(
                "Refusing to interrupt root. agents/interrupt fails closed on the root session."
            ));
        }
        let agent_id = self.resolve_agent_ref(agent_ref)?;
        self.ensure_caller_controls_descendant(&agent_id, caller_agent_id, "agents/interrupt")?;

        let prior = self.get_result_by_ref(&agent_id)?;
        if prior.status != SubAgentStatus::Running
            || self
                .agents
                .get(&agent_id)
                .is_some_and(|agent| agent.completion_claimed)
        {
            return Ok((prior.clone(), prior));
        }

        // Build a continuable checkpoint from the latest stored checkpoint or a
        // minimal placeholder so interrupt never drops recoverability silently.

View on GitHub (pinned to 73e0f67d83)