Skip to content

[FEATURE]: Non-blocking background task dispatch (like Claude Code's ^+B) #28034

@Dawnfz-Lenfeng

Description

@Dawnfz-Lenfeng

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:

  1. 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.
  2. Task polling/completion: The agent (or a system hook) receives a notification when the background task completes, with its stdout/stderr/exit code.
  3. 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

  1. Add background field to the bash tool schema
  2. When background=true, spawn the command in a detached process, return a task handle immediately
  3. Register the task in the session runtime so the agent can be notified on completion
  4. Optional: expose task_status / task_output tools for the agent to poll results

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions