github / github/copilot-cli

Ctrl+X B backgrounds only sync shell commands, not the subagent itself; running subagents also absent from /tasks (parity with Claude Code Ctrl+B)

Open
#3,845 0 comments 0 reactions 0 assignees View on GitHub
area:agents area:input-keyboard
Dominant language
Shell
Stars
11.2k
Forks
1.9k
Avg merge
14h 16m
Merged PRs (30d)
6

Description

## Describe the feature or problem you'd like to solve

`Ctrl+X → B` ("move current task to background") — and the `/tasks` overlay — operate on **sync shell commands**, not on a **subagent as a unit**. This produces two related gaps versus Claude Code (whose `Ctrl+B` backgrounds *"bash commands and agents"*, https://code.claude.com/docs/en/interactive-mode):

**1. A subagent whose current blocking work is NOT a shell command cannot be backgrounded.**
- If a foreground subagent is busy with model reasoning, code/file **search**, or edits, pressing `Ctrl+X → B` reports **"No running sync task to move to background."** The only way to reclaim the prompt is `Esc`, which cancels the turn and **kills the subagent's in-progress work**.
- If, instead, the subagent happens to be blocked on a **shell command** (e.g. `Start-Sleep`), `Ctrl+X → B` *does* work — but it backgrounds the **shell command**, not the subagent: it reports *"Moving current shell command (shellId: …) to background"*, the subagent then finishes its turn, and only the shell command persists in the background. So whether you can detach at all depends on *what the subagent is doing at that instant*, which is unpredictable from the user's side.

**2. Running subagents are not surfaced in `/tasks → Subagents`.**
- With a `Task(...)` subagent actively running, the `/tasks` overlay shows **"No subagents"**; only the subagent's nested shell command appears under **Shell Commands** as `[attached sync]`. There is no way to see or act on the subagent itself.

Net effect: for a long-running subagent that isn't sitting in a shell command, the user is blocked for its entire duration (wait) or must destroy its work (`Esc`). Claude Code lets you background the **agent** regardless of what it's currently doing.

## Proposed solution

Bring `Ctrl+X → B` (and the `/tasks` overlay) to parity with Claude Code's `Ctrl+B`:

1. Allow backgrounding the **subagent itself**, not just a sync shell command it may happen to be running — regardless of whether it's currently in a shell command, model turn, or other tool call.
2. After backgrounding, the subagent keeps running detached, the prompt is freed, and its result is folded back in on completion (the background-subagent notification path already exists for `mode: background` / `/fleet`).
3. **Surface running subagents under `/tasks → Subagents`** with navigate / background / kill actions, instead of showing "No subagents" while one is clearly running.

## Example prompts or workflows

1. "Search the whole codebase for every implementation of `IAsyncStorageDictionary` and summarize." (subagent doing **search**, not a shell command) → press `Ctrl+X → B` → today: "No running sync task"; desired: subagent detaches and keeps running while you continue.
2. A long research subagent ("research auth best practices for our stack") runs synchronously → background the **subagent** and keep editing in the same session.
3. From `/tasks`, navigate to a running **subagent** row and press `b` to background it (today the Subagents section shows "No subagents").

## Additional context

- **Repro A (gap):** dispatch a foreground subagent that does non-shell work (e.g. a codebase search), press `Ctrl+X → B` while it runs → **"No running sync task to move to background."**
- **Repro B (shell-command case that *does* work, for contrast):** dispatch a sync subagent that runs `Start-Sleep -Seconds 630`. `/tasks` shows **"No subagents"** + `Sleep for 630 seconds [attached sync]` under Shell Commands. `Ctrl+X → B` → *"Moving current shell command (shellId: sleep-task-1) to background"* → the queued prompt drains and the subagent finishes its turn; the sleep keeps running detached. (Confirms it backgrounds the *shell command*, not the *subagent*.)
- CLI version observed: `1.0.64-0`.
- Related issues:
- #3344 — messages submitted while background subagents run get stranded in the `Queued (N)` UI region.
- #3430 — `Esc` in `/tasks` overlay also dismisses the active question prompt.
- #2775 — agent gets stuck when canceling sub-agent tasks.
- Workaround today: launch the work in background mode from the start (ask the agent to "run it in the background"); but a subagent already running synchronously on non-shell work can't be detached without `Esc`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.