Skip to content

fix(agent-status): 后台子智能体运行期间保持忙碌状态 - #277

Merged
Ysheep666 merged 1 commit into
mainfrom
fix/claude-background-subagent-status
Nov 26, 2026
Merged

Ysheep666 merged 1 commit into
mainfrom
fix/claude-background-subagent-status

Conversation

@Ysheep666

Copy link
Copy Markdown
Contributor

问题

Claude Code 的 async 子智能体在父回合封账之后才结束:父回合先收到 transcript 终态,终端仍显示 Waiting for N background agents,而 9 个 SubagentStop 随后跨越多个新回合号陆续到达(实测跨越 20 多分钟、5 个不同 turnId)。原实现有三道闸门把状态直接压回 ready:

  1. 封账时 clearActiveWork() 退休了子工作账,迟到的 SubagentStop 已无账可结算;
  2. sealed-turn / foreign-turn / settled 闸门直接拒掉这些 SubagentStop;
  3. 投影层沿用封账瞬间的状态快照,之后没有任何路径能把它重算回 ready。

改动

  • 可信终态只退休本回合自己的工具与交互,仍在运行的子工作被 carry 过来,并继续受 hook 静默期限约束;
  • SubagentStop 豁免 settled / abandoned / foreign-turn / sealed 四道闸门;SubagentStart 仍受约束,迟到的新子工作不能把已封账回合拖回忙碌;
  • 封账回合的投影状态按剩余子工作重算(statusForSealedTurn),最后一个子工作结束才回 ready;
  • 子工作关联的退休收窄为仅换代(reset / 会话结束),可信终态封账不再退休。

状态现在在后台子智能体运行期间显示 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 fixes
  • pnpm preflight:push → unit 14579 passed / component 704 passed

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.
@Ysheep666
Ysheep666 merged commit e0f83ba into main Nov 26, 2026
8 checks passed
@Ysheep666
Ysheep666 deleted the fix/claude-background-subagent-status branch November 26, 2026 11:57
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