{"record":{"id":"d1654883cfa11f6f","repo":"Hmbown/CodeWhale","slug":"sub-agents-run-in-the-background-and-cannot-use-ba","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":18437,"sourceCode":"    };\n    raw_paths\n        .into_iter()\n        .map(|path| normalize_claim_path(&path).map_err(anyhow::Error::msg))\n        .collect()\n}\n\nfn reject_subagent_terminal_takeover(name: &str, input: &Value) -> Result<()> {\n    let wants_interactive_shell = matches!(name, \"bash\" | \"Bash\" | \"exec_shell\")\n        && input\n            .get(\"action\")\n            .and_then(Value::as_str)\n            .is_none_or(|action| action == \"run\")\n        && input\n            .get(\"interactive\")\n            .and_then(Value::as_bool)\n            .unwrap_or(false);\n    if wants_interactive_shell {\n        return Err(anyhow!(\n            \"Sub-agents run in the background and cannot use Bash with interactive=true \\\n             because that would take over the parent TUI terminal. Use Bash without \\\n             interactive, or with background=true / tty=true, or task_shell_start \\\n             instead.\"\n        ));\n    }\n    Ok(())\n}\n\n/// Resolve the effective allowed-tools list for a child.\n///\n/// **v0.6.6 default: full inheritance.** Returning `Ok(None)` means the\n/// child sees the same tool surface as the parent's Agent mode — every\n/// family including `with_subagent_tools` so it can recurse. The narrowing\n/// path (`Ok(Some(list))`) is only used by:\n/// - `Custom` agent types (which require an explicit list).\n/// - Callers that pass `explicit_tools` (advanced / legacy use).\n///","sourceCodeStart":18419,"sourceCodeEnd":18455,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/mod.rs#L18419-L18455","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove `interactive: true` and run Bash non-interactively","Use `background=true` or `tty=true` instead of interactive","Use `task_shell_start` for shell sessions from a sub-agent","Move the interactive command to the parent agent instead"],"exampleFix":"// before\nsubagent.call(\"Bash\", { command: \"python\", interactive: true })\n// after\nsubagent.call(\"Bash\", { command: \"python script.py\", background: true })","handlingStrategy":"validation","validationCode":"if (isSubagent && input.interactive === true) {\n  throw new Error('interactive Bash not allowed in sub-agents; use background/tty');\n}","typeGuard":"const wantsInteractive = (input) => input.interactive === true;","tryCatchPattern":null,"preventionTips":["Never copy interactive Bash invocations into sub-agent prompts","Use background=true or task_shell_start for sub-agent shells","Document the terminal-ownership constraint in sub-agent templates"],"tags":["subagent","bash","terminal"],"backgroundTag":"conflicting-config-options","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"}