Repository navigation
fix(supervisor): a bot is busy while its subagents and own turns run - #26
Merged
Merged
Conversation
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).
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
turnsstayed at 0.Change
system/initwith no pending turn is a turn of Claude Code's own: the bot isbusyuntil itsresult, which does not consume a written message's turn.system/background_tasks_changed(the full list of background tasks, each time) keeps the botbusywhile anylocal_agentruns. Background shell commands and monitors are ignored, so a dev server left running does not pin the bot as busy.Tested
cargo fmt,clippy -D warnings,cargo test --workspacepass; new tests cover the own turn (also with a message arriving during it) and the subagent list.-pstream-json, two background subagents): confirmed theresult-before-subagents order, thebackground_tasks_changedshape 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.