Repository navigation
fix(subagents): key the collected-result mark by run, not session (#987) - #989
Merged
Merged
Conversation
…egr#987) get_subagent_result marks every terminal background result it returns, but only notifyParent ever takes that mark. When the parent polls after the notification was already delivered, the mark stays behind keyed by the child session id. resume reruns the same session id, so that stale mark swallowed the next run's completion notification and left the parent waiting for a notification that never came. Record the collected run's completedAt with the mark and only drop a notification whose run matches it. A resumed run always gets a new completedAt, so a mark left by an earlier run can no longer match it. resume deliberately leaves the mark in place: the parent can collect a run and resume it in the same turn while that run's notification is still held, and the mark must keep suppressing it (agegr#889).
This was referenced Sep 29, 2026
…ed failure The collected-result mark is set for every terminal background result, failed ones included, so the agegr#987 loss also hits a retry: run 1 fails, the parent inspects the failure with get_subagent_result, resumes the child, and the retry is rejected by the provider at once. On main the retry's failure notification was taken by run 1's mark and the parent kept waiting. Lock that path in: the retry's failure must still reach the parent.
Owner
|
Reviewed. #987 is real, and the mechanism is exactly as described: What I checked:
The new tests fail against Generated by Claude Code |
This was referenced Sep 30, 2026
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…egr#987) (agegr#989) * fix(subagents): key the collected-result mark by run, not session (agegr#987) get_subagent_result marks every terminal background result it returns, but only notifyParent ever takes that mark. When the parent polls after the notification was already delivered, the mark stays behind keyed by the child session id. resume reruns the same session id, so that stale mark swallowed the next run's completion notification and left the parent waiting for a notification that never came. Record the collected run's completedAt with the mark and only drop a notification whose run matches it. A resumed run always gets a new completedAt, so a mark left by an earlier run can no longer match it. resume deliberately leaves the mark in place: the parent can collect a run and resume it in the same turn while that run's notification is still held, and the mark must keep suppressing it (agegr#889). * test(subagents): cover a resumed run that fails right after a collected failure The collected-result mark is set for every terminal background result, failed ones included, so the agegr#987 loss also hits a retry: run 1 fails, the parent inspects the failure with get_subagent_result, resumes the child, and the retry is rejected by the provider at once. On main the retry's failure notification was taken by run 1's mark and the parent kept waiting. Lock that path in: the retry's failure must still reach the parent. --------- Co-authored-by: CLAY777 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…egr#987) (agegr#989) * fix(subagents): key the collected-result mark by run, not session (agegr#987) get_subagent_result marks every terminal background result it returns, but only notifyParent ever takes that mark. When the parent polls after the notification was already delivered, the mark stays behind keyed by the child session id. resume reruns the same session id, so that stale mark swallowed the next run's completion notification and left the parent waiting for a notification that never came. Record the collected run's completedAt with the mark and only drop a notification whose run matches it. A resumed run always gets a new completedAt, so a mark left by an earlier run can no longer match it. resume deliberately leaves the mark in place: the parent can collect a run and resume it in the same turn while that run's notification is still held, and the mark must keep suppressing it (agegr#889). * test(subagents): cover a resumed run that fails right after a collected failure The collected-result mark is set for every terminal background result, failed ones included, so the agegr#987 loss also hits a retry: run 1 fails, the parent inspects the failure with get_subagent_result, resumes the child, and the retry is rejected by the provider at once. On main the retry's failure notification was taken by run 1's mark and the parent kept waiting. Lock that path in: the retry's failure must still reach the parent. --------- Co-authored-by: CLAY777 <[email protected]>
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.
Fixes #987. The issue has the real-session evidence (154 background dispatches, 106 without a notification) and the full mechanism; this PR is the fix it suggests.
Problem
#937 (for #889) made
get_subagent_resultmark every terminal background result it returns, andnotifyParentdrops a notification when it can take that mark. The mark is keyed only by the child session id, and onlynotifyParentever removes it.When the parent polls after the notification was already delivered, the mark stays behind with nothing to take it.
resumereruns the same session id, so the next run'snotifyParenttakes that stale mark and returns without notifying. The parent then waits for a notification that never comes. A human nudge usually makes the parent poll again, which leaves a fresh stale mark, so the loss repeats on every later run.Change
lib/subagent-runtime.ts: the mark stores the collected run'scompletedAt(Map<sessionId, completedAt>), andtakeResultConsumed(run)only matches the same run. A resumed run always gets a newcompletedAt, so a mark left by an earlier run can no longer match it.resumedeliberately does not clear the mark: the parent can collect a run and resume it in the same turn while that run's notification is still held, and the mark must keep suppressing it. TheglobalThisgetter replaces a pre-changeSetleft behind by hot reload.lib/subagent-extension.ts:get_subagent_resultpasses the run instead of the bare session id.AGENTS.md: one sentence added to the existing notification note.#889 behaves as before: a result the parent collects while that same run's notification is held still suppresses it.
Tests
get_subagent_result, resumes, and the retry fails at once (provider 400) → the retry's failure notification still reaches the parent. The mark is set for every terminal status, so failed runs hit Background subagent completion is silently dropped for the next run of the same subagent (parent stays idle until a human nudges it) #987 the same way.mainand pass with the change.npx tsc --noEmitandnpm run lintare clean.npm test: all subagent tests pass. The only failures are the existing Windows-host ones (CRLF / PTY / path delimiter), and they fail onmaintoo.