Hmbown/CodeWhale · error · anyhow::Error

Sub-agents run in the background and cannot use Bash with…

Error message

Sub-agents run in the background and cannot use Bash with interactive=true because that would take over the parent TUI terminal. Use Bash without interactive, or with background=true / tty=true, or task_shell_start instead.

What it means

Sub-agents execute in the background, so an interactive Bash session (interactive=true) would seize the parent TUI's terminal, which is impossible. The guard rejects Bash calls that combine a shell-spawning action with interactive=true and points at background/tty/task_shell_start alternatives.

Solutions

  1. Remove `interactive: true` and run Bash non-interactively
  2. Use `background=true` or `tty=true` instead of interactive
  3. Use `task_shell_start` for shell sessions from a sub-agent
  4. Move the interactive command to the parent agent instead

Example fix

// before
subagent.call("Bash", { command: "python", interactive: true })
// after
subagent.call("Bash", { command: "python script.py", background: true })
Defensive patterns

Strategy: validation

Validate before calling

if (isSubagent && input.interactive === true) {
  throw new Error('interactive Bash not allowed in sub-agents; use background/tty');
}

Type guard

const wantsInteractive = (input) => input.interactive === true;

Prevention

When it happens

Trigger: A sub-agent calls the Bash tool with `interactive: true` (and action `run` or unset), or omits interactive while the caller expected interactivity; any value of `interactive` that parses as a truthy bool triggers it.

Common situations: A model tries to open an interactive REPL or editor from a sub-agent; a prompt copied from parent-agent usage passes interactive=true; porting a parent Bash invocation verbatim into a sub-agent.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

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

    };
    raw_paths
        .into_iter()
        .map(|path| normalize_claim_path(&path).map_err(anyhow::Error::msg))
        .collect()
}

fn reject_subagent_terminal_takeover(name: &str, input: &Value) -> Result<()> {
    let wants_interactive_shell = matches!(name, "bash" | "Bash" | "exec_shell")
        && input
            .get("action")
            .and_then(Value::as_str)
            .is_none_or(|action| action == "run")
        && input
            .get("interactive")
            .and_then(Value::as_bool)
            .unwrap_or(false);
    if wants_interactive_shell {
        return Err(anyhow!(
            "Sub-agents run in the background and cannot use Bash with interactive=true \
             because that would take over the parent TUI terminal. Use Bash without \
             interactive, or with background=true / tty=true, or task_shell_start \
             instead."
        ));
    }
    Ok(())
}

/// Resolve the effective allowed-tools list for a child.
///
/// **v0.6.6 default: full inheritance.** Returning `Ok(None)` means the
/// child sees the same tool surface as the parent's Agent mode — every
/// family including `with_subagent_tools` so it can recurse. The narrowing
/// path (`Ok(Some(list))`) is only used by:
/// - `Custom` agent types (which require an explicit list).
/// - Callers that pass `explicit_tools` (advanced / legacy use).
///

View on GitHub (pinned to 73e0f67d83)