fix(agent-runtime): deliver delegate reports that settled before the parent idled - #228
Merged
vastsa merged 1 commit intoSep 11, 2026
Conversation
…parent idled resumeAfterDelegations kept the turn open and auto-fed reports only while delegates of the current turn were still running. A delegate that finished before the parent went idle, with no TaskWait in between, was settled but never delivered: runningDelegations() was empty, the resume loop returned, and the parent continued as if the delegate had produced nothing. The wait set is now "current turn, report not yet delivered": a new reportDelivered flag on each record, pendingCurrentTurnDelegations() as the loop/keep-open condition, and single-shot delivery. TaskWait marks the settled records it returned as delivered so the idle resume does not repeat them; still-running records keep their shot, so a timeout or an early mode "any" convergence does not consume a future auto-resume. Stopped and aborted runs are not auto-delivered, as before. Refs vastsa#226
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Owner
|
Merged PR #228 with the contributor commit preserved. The linked idle-parent race is real: the previous resume path only considered currently running delegates, so a settled same-turn report could be skipped.\n\nFollow-up fix landed locally after the merge in |
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 #226.
resumeAfterDelegationskept the turn open and auto-fed reports only while delegates of the current turn were still running (currentTurnDelegations()filtersrunningDelegations()). A delegate that finished before the parent went idle, with noTaskWaitin between, was settled but never delivered: the running set was empty, the loop returned, and the parent continued as if the delegate had produced nothing. As the issue puts it, such a report is "done and unpublished", not "unfinished".Change (
packages/agent-runtime/src/runtime.ts), following the proposal in the issue:DelegationRecord.reportDeliveredmarks a report that reached the parent's context once.pendingCurrentTurnDelegations(): sameturnEpoch,!reportDelivered, notstopped/aborted.keepTurnOpenForDelegates()keeps the turn open while running or pending-undelivered delegates exist.resumeAfterDelegationsloops over the pending set, waits (settled records resolve immediately inwaitForDelegations), injects only settled records that are still undelivered and marks them delivered once.TaskWaitmarks the settled records it returned as delivered, so the idle resume does not repeat them; still-running records keep their shot, so a timeout or an earlymode: "any"convergence does not consume a future auto-resume.runCancelled/turnHadErrorguards stay.Tests (
runtime.test.ts): a delegate that settles before the parent idles is delivered exactly once through the resume prompt and the turn stays open until then (fails onmain: the prompt is never called); a report already returned byTaskWaitis not replayed on idle.npx vitest run src/runtime.test.ts→ 141 passed;tsc --noEmitclean for the package.