Skip to content

fix(supervisor): a bot is busy while its subagents and own turns run - #26

Merged
httpsphl merged 1 commit into
mainfrom
fix/busy-while-working
Sep 29, 2026
Merged

httpsphl merged 1 commit into
mainfrom
fix/busy-while-working

Conversation

@httpsphl

Copy link
Copy Markdown
Owner

Problem

A bot that launched subagents showed as Available while it was clearly working. In a real chat, the first turn ended when the subagents were launched; three more turns then ran that Claude Code started by itself as each subagent finished, with no message written for them. The daemon only counted turns it had written, so turns stayed at 0.

Change

  • system/init with no pending turn is a turn of Claude Code's own: the bot is busy until its result, which does not consume a written message's turn.
  • system/background_tasks_changed (the full list of background tasks, each time) keeps the bot busy while any local_agent runs. Background shell commands and monitors are ignored, so a dev server left running does not pin the bot as busy.
  • A pending mode/model restart also waits for the subagents.
  • Spec 7.1, 7.2, 8.1 updated; section 19 records the real run.

Tested

  • cargo fmt, clippy -D warnings, cargo test --workspace pass; new tests cover the own turn (also with a message arriving during it) and the subagent list.
  • Real Claude Code 2.1.284 (Haiku, -p stream-json, two background subagents): confirmed the result-before-subagents order, the background_tasks_changed shape and the self-started turns.

Manual step

In the app, ask a bot to research something with parallel subagents: its status should read "Working" from the first message until the last self-started turn ends.

Claude Code ends a turn while background subagents still work, then starts
turns by itself when they finish. The daemon only counted turns it had
written, so the bot showed as available during all of that. A system/init
with no pending turn is now a turn of its own, and
system/background_tasks_changed keeps the bot busy while subagents run.
Tested with Claude Code 2.1.284 (spec 19).
@httpsphl
httpsphl merged commit 645616f into main Sep 29, 2026
3 checks passed
@httpsphl httpsphl mentioned this pull request Sep 29, 2026
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.

1 participant