fix(spool): classify detached lanes waiting on their own background subagent as failed - #1149
Merged
Merged
Conversation
…kground subagent as failed (#1130) A detached run's terminal `result` event can report a clean, non-error success while the lane's last turn was still waiting on a background Task/Agent subagent it spawned and never got a result back from — in a detached lane there is no next turn to resume that wait, so the run is recorded as a zero-deliverable "completed" forever. `stream-json.ts` now correlates Agent/Task tool_use ids against later tool_result blocks (same shape exec-events.ts already uses for the obs events file) and exposes the count left unresolved by stream end. `spool.ts`'s reconcile — extended for the sibling "claude's own terminal state can lie" case in #1131 — now also reclassifies to failed when that count is nonzero AND the run produced no commit/PR/issue, without relying on matching the model's free-form "I'll pause here" phrasing. Closes #1130
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Closes #1130.
A detached lane's terminal
resultevent can report a clean, non-errorsuccess while the lane's own last turn was still waiting on a background
Task/Agent subagent it spawned and never got a result back from ("I'll pause
here until it completes"). In a detached lane there is no next turn to
resume that wait — the run gets recorded as a zero-deliverable "completed"
forever (repro'd twice on 2026-07-14/15, see issue).
This is a distinct terminal-state class from #1123's deliver-and-stop CI
gate (which verifies CI on a PR the lane already believes it produced) —
here the lane never produced anything to gate.
Fix, built on the same seam #1131 added for "claude's own terminal
state can lie":
stream-json.tsnow correlatesAgent/Tasktool_use ids against latertool_resultblocks (the same shapeexec-events.tsalready uses for theobs events file) and exposes the count left unresolved by the time the
stream ends as
openBackgroundSubagents.spool.ts's reconcile (toRecord) adds a third branch to the existing#1131reclassification chain: asawResult && !isErrorrun isreclassified to
failedwhenopenBackgroundSubagents > 0and therun produced zero commits/PRs/issues. A subagent that resolved before the
stream ended, or a run that still delivered a commit/PR/issue despite a
dangling background task, are both left
completed.Structural, not text-matching — the issue's own follow-up comment notes a
second occurrence phrased the "waiting" differently ("waiting for the
automatic notification" vs. "I'll pause here"), so regexing the model's
free-form text would just chase rewordings. Whether a synchronous subagent
call resolved before the parent turn ended is a hard fact of the stream.
Test plan
npm run typecheck— passnpm run build— passnpm test— 2365/2365 pass (145 files), including new cases:test/stream-json-parser.test.ts: open/resolved/ignored subagent tool_use trackingtest/spool.test.ts: the exact repro (clean result + hanging subagent + zero deliverable → failed), resolved-subagent stays completed, delivered-PR-with-dangling-subagent stays completed, legacy plain-text logs untouchednpm run lint— 0 errors (pre-existing warnings only, unrelated to this change)