fix(subagents): killed subagent runs stay running in the task list#99806
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 5:03 AM ET / 09:03 UTC. Summary PR surface: Source +1805, Tests +6146. Total +7951 across 46 files. Reproducibility: yes. from source inspection: current main records killed subagent terminal state without finalizing the mirrored detached task row, matching the linked stuck-running task report. I did not run a live reproduction in this read-only review. Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land this runtime reconciliation only after current-head validation and a deliberate supersession or split decision for the older repair, keeping #90444 open for historical cleanup if needed. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main records killed subagent terminal state without finalizing the mirrored detached task row, matching the linked stuck-running task report. I did not run a live reproduction in this read-only review. Is this the best way to solve the issue? Yes, this appears to be the best owner-boundary fix because it reconciles direct kill, late provider completion, explicit task cancellation, restart, and stale-generation ownership in the lifecycle/task paths rather than relying only on later maintenance cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3957ccba4e59. Label changesLabel justifications:
Evidence reviewedPR surface: Source +1805, Tests +6146. Total +7951 across 46 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (6 earlier review cycles)
|
|
Non-approval review note after reading the current head and the adjacent task/subagent lifecycle paths: I do not see a source-level blocker in this pass. Moving the cancelled task-row finalization into What I checked:
node scripts/run-vitest.mjs src/agents/subagent-control.test.ts -- -t "finalizes the detached task row|finalizes the same way|task-row finalize" --reporter=verboseThat selected 2 passing tests in One small evidence caveat: the PR body says At the time I checked, the relevant CI/check shards were passing; |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
eb9f0a2 to
c48ae32
Compare
c48ae32 to
19f7057
Compare
Co-authored-by: masatohoshino <[email protected]>
4f3ed83 to
7f8f505
Compare
Related: #90444
What Problem This Solves
Killing a subagent could leave its detached task row running forever, while a provider completion arriving during cancellation could race the registry, task ledger, session timing, cleanup, and delivery paths into contradictory terminal states.
Why This Change Was Made
The original PR correctly identified the missing task finalization, but direct finalization alone made cancellation sticky too early and did not survive restarts, steer replacements, split persistence, or same-session generations.
This rewrite gives each subagent run a durable task owner and monotonic generation, records direct kills as provisional reconciliation markers, and arbitrates provider completion against stable operator cancellation. Task projection commits before registry publication, interrupted task-first commits replay from durable evidence, and session writes, cleanup, hooks, list/control views, and announcement dedupe all recheck generation ownership. Failed steer cleanup remains best-effort so a custom task runtime cannot strand the old run in suppressed state.
User Impact
runningrows.tasks.cancelremains sticky against a later provider result.Evidence
succeeded;tasks.cancel-> late provider success remainedcancelled;succeeded.tbx_01kwrjd9a5b535wqj88qr1x47hpassed the full changed gate: production/testtsgo, exhaustive core lint, import-cycle check, database-first guard, runtime sidecar guard, media/webhook/pairing guards. Actions proofScope
This fixes new kill/completion reconciliation and restart durability. #90444 remains open for historical stuck-row cleanup and broader maintenance repair.