Skip to content

fix: only count subagents that are really running - #160

Merged
brtkwr merged 1 commit into
mainfrom
fix/subagents-current-process
Oct 28, 2026
Merged

brtkwr merged 1 commit into
mainfrom
fix/subagents-current-process

Conversation

@brtkwr

@brtkwr brtkwr commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

ccs said `ccs-improvements` had 32 running subagents and `dual-accept-key-rotation` 119. Neither was true.

Why:

  • Most of their subagents' `meta.json` files have no `finished` field at all, because older Claude Code didn't write one. ccs read a missing flag as "still running".
  • They were also days old, from claude processes that had since exited or been resumed.
  • The remaining few were review teammates that were never shut down: alive, but idle for 8 days.

Now a subagent counts as running only if all of these hold:

  • it isn't marked finished
  • its session is open in claude
  • it was started by the session's current claude process (the same rule background tasks use)
  • it has written to its transcript in the last 10 minutes

One that's alive but quiet for longer shows as idle. The preview's grey line now counts idle, finished and ended with the session. A start time comes from the first of a transcript's first lines that has a timestamp, or from the file's date.

Checked on real sessions:

session before after
ccs-improvements 32 running 0 running; 1 finished, 32 ended with the session
dual-accept-key-rotation 119 running 0 running; 4 idle, 34 finished, 115 ended with the session
dependabot-sweep-workflow 7 running 0 running; 6 idle (quiet for over an hour), 15 finished, 1 ended

Test: `TestSubagentsInThePreviewAndTheList` now covers an idle teammate and a subagent from before a resume.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QUnP8jVL2NG9cWmohJTyun

Older Claude Code wrote no finished flag, so every old subagent counted
as running: 32 on ccs-improvements, 119 on dual-accept-key-rotation. A
subagent now counts only if its session's current claude process started
it (a resume or exit ends them without a word) and it has written to its
transcript in the last 10 minutes; one alive but quiet longer is idle,
like a teammate waiting to be shut down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUnP8jVL2NG9cWmohJTyun
@brtkwr
brtkwr enabled auto-merge October 28, 2026 10:45
@brtkwr
brtkwr merged commit 1f3d2fe into main Oct 28, 2026
1 check passed
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