Summary
When running a long bash command (e.g. npm test, docker build, pytest), the agent is blocked until the command finishes. There is no way to dispatch a terminal task to the background, let the agent continue working, and get notified when the task completes.
Problem
Currently, any bash command issued by the agent blocks the entire session:
- The agent cannot work on other files while waiting for a test run to finish
- The user cannot switch to another sub-agent or task during a long build
- There is no mechanism to "fire and forget" a terminal command and be notified of its result
Claude Code solves this with ^+B — the user presses Ctrl+B while a command is running, which detaches it to the background. The agent continues its conversation, and when the task finishes, the agent is notified inline.
Proposed Solution
Add a background task dispatch mechanism:
- At the bash tool level: Add a
background: bool parameter (default false). When true, the command is dispatched to a background shell process and returns immediately with a task ID.
- Task polling/completion: The agent (or a system hook) receives a notification when the background task completes, with its stdout/stderr/exit code.
- TUI keybind (bonus): Allow the user to press a key (e.g.
^+B) to detach a currently running bash command to the background, freeing the agent to continue.
Example UX
Agent runs: !npm test -- --watch
User presses: ^+B
→ Task #42 dispatched to background (webpack watch mode)
Agent continues conversation freely
...later, system message:
→ [Task #42 completed] npm test -- --watch — exit code 0 (12 tests passed)
Difference from existing subagent/background-subagent
This is not about spawning a sub-agent to do AI work. This is specifically about non-blocking bash command execution:
- Existing:
task(background=true, ...) spawns a sub-agent for AI research tasks
- Proposed: The bash tool itself supports a
background flag, allowing any shell command to run async without blocking the agent
Use Cases
- Run
pytest in background while continuing to edit code
docker build in background, keep working on unrelated files
- Start a dev server in background (
npm run dev), then continue editing
- Run a long query against a database while the agent reads related code
Implementation Sketch
- Add
background field to the bash tool schema
- When
background=true, spawn the command in a detached process, return a task handle immediately
- Register the task in the session runtime so the agent can be notified on completion
- Optional: expose
task_status / task_output tools for the agent to poll results
Summary
When running a long bash command (e.g.
npm test,docker build,pytest), the agent is blocked until the command finishes. There is no way to dispatch a terminal task to the background, let the agent continue working, and get notified when the task completes.Problem
Currently, any bash command issued by the agent blocks the entire session:
Claude Code solves this with
^+B— the user presses Ctrl+B while a command is running, which detaches it to the background. The agent continues its conversation, and when the task finishes, the agent is notified inline.Proposed Solution
Add a background task dispatch mechanism:
background: boolparameter (defaultfalse). Whentrue, the command is dispatched to a background shell process and returns immediately with a task ID.^+B) to detach a currently running bash command to the background, freeing the agent to continue.Example UX
Difference from existing subagent/background-subagent
This is not about spawning a sub-agent to do AI work. This is specifically about non-blocking bash command execution:
task(background=true, ...)spawns a sub-agent for AI research tasksbackgroundflag, allowing any shell command to run async without blocking the agentUse Cases
pytestin background while continuing to edit codedocker buildin background, keep working on unrelated filesnpm run dev), then continue editingImplementation Sketch
backgroundfield to the bash tool schemabackground=true, spawn the command in a detached process, return a task handle immediatelytask_status/task_outputtools for the agent to poll results