Skip to content

feat: keep background agents running when the main agent stops - #13641

Merged
marius-kilocode merged 6 commits into
mainfrom
improve-esc-subagent-control
Sep 1, 2026
Merged

feat: keep background agents running when the main agent stops#13641
marius-kilocode merged 6 commits into
mainfrom
improve-esc-subagent-control

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

In the VS Code extension, Esc and the main Stop button cancelled asynchronous subagents along with the parent. Interrupting the parent to send a correction could therefore discard background work.

Why This Change Was Made

Separate parent interruption from deliberate background cancellation. The abort endpoint accepts scope=session to stop the current turn and foreground work while preserving asynchronous children. The default scope=tree remains unchanged for lifecycle shutdowns and other clients.

A per-session pause gate retains completed background results without restarting an interrupted parent. Sending a message or using Continue resumes the parent with those results. The review fixes also keep paused background injections inactive across a later continuation and prevent an invalid slash command from unpausing a stopped session.

User Impact

  • Esc, main Stop, and retry cancellation preserve background agents.
  • The existing top background-agent bar gains a direct Stop all (N) action for that session's running background jobs. It does not stop the parent or ask for confirmation.
  • No new composer count, extra spinner, shared UI provider, toast, or transcript status is added. Existing progress indicators and layout remain unchanged.

Evidence

  • Six focused backend regression tests cover scoped interruption, retained results, continuation, default/tree cancellation, foreground-child cleanup, and the two pause-gate review findings.
  • Existing task model-selection tests pass after merging the current base.
  • The Stop-all browser test reuses the existing TaskHeader story and verifies exact cancellation targets with no parent abort. Existing pointer-accessibility and spinner-stability checks cover the unchanged agent bar.
  • Package typechecks, lint, focused unit tests, and the shared-code annotation and Promise-facade guards pass.

The earlier isolated VS Code run verified parent-only interruption and retained results against a local test model. The reduced UI is covered by browser tests; the isolated VS Code relaunch failed in the local test harness, so there is no claim of a fresh native-editor end-to-end run.

Escape and the main Stop button now abort only the current session's turn and foreground work, so asynchronous subagents keep running and their results are retained until the user sends the next message.

Adds a shared background-agent state provider, a session-dock activity count that opens the existing top agent bar, and per-agent plus stop-all controls there.
The count button now shows the running total with the existing background-agent string as its accessible name, so the duplicate badge translations are removed from all locales.
Keeps scoped stop with retained results, continuation after a background result, tree-scope descendant cancellation, and foreground-versus-async child handling. Drops the promoted-child, attachment-intake, queued-continuation, gate, and extra-width cases, and restores the simpler agent row loop.
Comment thread packages/opencode/src/kilocode/session/control.ts Outdated
Comment thread packages/opencode/src/session/prompt.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/kilo-vscode/tests/fixtures/session-provider-activity.tsx
  • script/architecture-allowlist.json
Previous Review Summary (commit 9d2a4ac)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 9d2a4ac)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • packages/kilo-docs/public/img/screenshot-tests/kilo-vscode/visual-regression/chat/task-header-background-agents-200-chromium-linux.png
  • packages/kilo-docs/public/img/screenshot-tests/kilo-vscode/visual-regression/chat/task-header-background-agents-420-chromium-linux.png
  • packages/kilo-vscode/tests/fixtures/session-provider-activity.tsx
  • script/architecture-allowlist.json

Reviewed by grok-4.6 · Input: 194.8K · Output: 4.8K · Cached: 82.2K

Review guidance: REVIEW.md from base branch main

Merge current main and remove the composer activity UI, keeping Stop all in the existing background-agent bar.

Keep paused background tickets inactive after continuation and prevent failed commands from resuming stopped sessions.
@marius-kilocode
marius-kilocode force-pushed the improve-esc-subagent-control branch from 9d2a4ac to 1954690 Compare September 1, 2026 10:04
@marius-kilocode
marius-kilocode merged commit 5fbc380 into main Sep 1, 2026
36 checks passed
@marius-kilocode
marius-kilocode deleted the improve-esc-subagent-control branch September 1, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants