Repository navigation
fix(agent-status): 后台子智能体运行期间保持忙碌状态 - #277
Merged
Merged
Conversation
Claude Code's async subagents keep running after the parent turn seals: the transcript terminal arrives first, then the SubagentStops trickle in across several later turn ids. Three gates used to collapse that state to ready immediately: - turn bookkeeping retired the subagent ledger at seal time, so the late SubagentStops had nothing left to settle; - the sealed-turn / foreign-turn gates rejected those SubagentStops; - the projection reused the seal-time status snapshot, so nothing could ever recompute it back to ready. Now a trusted terminal only retires the turn's own tools and interactions; still-running subagent work is carried over and stays subject to the hook silence deadline. SubagentStop is exempt from the settled / abandoned / foreign-turn / sealed gates, while SubagentStart stays gated so a late start cannot drag a sealed turn back to busy. Projected status for a sealed turn is recomputed from the remaining subagent work, and the retirement of subagent associations is narrowed to turn resets only. Status now shows processing while background agents run and returns to ready when the last one settles.
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.
问题
Claude Code 的 async 子智能体在父回合封账之后才结束:父回合先收到 transcript 终态,终端仍显示
Waiting for N background agents,而 9 个SubagentStop随后跨越多个新回合号陆续到达(实测跨越 20 多分钟、5 个不同 turnId)。原实现有三道闸门把状态直接压回 ready:clearActiveWork()退休了子工作账,迟到的SubagentStop已无账可结算;sealed-turn/foreign-turn/ settled 闸门直接拒掉这些SubagentStop;改动
SubagentStop豁免 settled / abandoned / foreign-turn / sealed 四道闸门;SubagentStart仍受约束,迟到的新子工作不能把已封账回合拖回忙碌;statusForSealedTurn),最后一个子工作结束才回 ready;状态现在在后台子智能体运行期间显示 processing,最后一个结束后回到 ready。
规格与测试
docs/superpowers/specs/2026-09-06-agent-status-evidence-gold-standard.md新增### 封账后仍在运行的后台子智能体tests/unit/main/panel/foreground-activity-background-subagents.test.ts(7 用例)tests/unit/agent-integrations/cursor.test.ts(Cursor Task 是同步子智能体,SubagentStop先于stop到达)验证
pnpm typecheck全绿pnpm lint→ 5278 files, no fixespnpm preflight:push→ unit 14579 passed / component 704 passed