Repository navigation
Conversation
Contributor
|
Thanks for this, @jlongster! The Please open it again with |
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.
Problem
A subagent reported its final message to the parent as soon as its child session went idle, even if the child still had background work running (background shell commands, its own background subagents). When that work finished later, its notice woke the child again, but the parent had already received a stale result, and the child's real final answer was never reported.
Root cause
The subagent job's
runeffect (SubagentJob.start, and the restart-recovery equivalent inSessionRestart) was simplyresume(child)followed by reading the latest assistant message. Nothing checked the background jobs the child owned.Change
Adds
SubagentCompletion.settle(jobs, childID, resume). It uses the existing durable background markers (Job.pendingBackground), keyed by owner:recovery.sessionIDfor shells andrecovery.parentSessionIDfor subagents.jobs.waiton the owned jobs that are still running, then repeat. A finished job's marker is only cleared after its notification has been admitted to the child's inbox, so the nextresumedrains that notice. The text reported to the parent is then the child's final message after all of its background work.Both the live subagent job and restart recovery now use
settle.Tests
tool-subagent.test.tscase: the child owns a running background job, and the parent gets no completion until that job finishes and its notice is admitted. This test fails without the fix.bun typecheckinpackages/core. Rantool-subagent,subagent-lifetime,session-execution,job,tool-shellandintegrationtests: all pass.Risks