Repository navigation
Conversation
`get_subagent_result` reported "Subagent not found" for a background run that had finished moments earlier. Settling deletes the live record, the child's wrapper is released once the child goes idle, and the session file can still be unresolvable right after it settled: with all three gone, nothing answered for an id this process had handed out itself, and the parent had no way to check the claim — it reasonably reads it as the child's session having been deleted. - A settled run moves to `getSettledSubagentRuns()` (64 entries, insertion order) instead of vanishing. `get()` consults it only after a live wrapper and a read of the session file have both failed, so a fresh read of the file always wins and an id that was never run is still reported as unknown. - `resume` re-registers the run live, and a resume that settles again overwrites the record, so the fallback cannot serve a superseded result. - The new test settles a run, then takes away both the wrapper and the path lookup and still expects the completed result. It fails without the fix (node --test and bun test alike) and passes with it.
brynne8
force-pushed
the
fix/subagent-settled-run-findable
branch
from
October 12, 2026 03:11
659a361 to
351e729
Compare
This branch has not been deployed
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.
What breaks today
A parent dispatches a background
Agentrun, the child finishes, and the parent's nextget_subagent_result({ sessionId })— for the very id theAgentcall just returned — answers "Subagent not found". The parent has no way to check that claim, so it reasonably concludes the child's session was deleted, and either re-does the work or reports a loss that never happened.Why it happens
Three lookups in
get()all come up empty at once, right after a run settles:getSubagentRuns().delete(...)at the six settle points).AgentSessionWrapperis released once the child goes idle, so there is no live wrapper to read from.dependencies.resolveSessionPath(sessionId)can still miss a session that settled moments ago.With all three gone, nothing answered for an id this process had handed out itself.
The fix
getSettledSubagentRuns()— a bounded map (64 entries, insertion order) — instead of vanishing.get()consults it only after both the live wrapper and the session-file read have failed.What the fallback deliberately cannot do:
getreturnsnull).resumere-registers the run live, and a re-settled resume overwrites the record.Test evidence
The new test is behavioural: it resumes/settles a run against the real controller, then takes away both the wrapper (
getSessionreturns nothing,resolveSessionPathreturnsnull) and assertsget()still returns the completed result with the resumed run's text; it also asserts an id nothing ever ran is stillnull. No source-text assertions.main(test kept, fix stashed):bun test lib/subagent-runtime.test.mjs→14 pass / 1 fail(AssertionError: actual: undefined, expected: "completed")node --experimental-strip-types --test lib/subagent-runtime.test.mjs→ same single failure15 pass / 0 failnpm test:2627 tests, 2626 pass, 0 fail, 1 skippedbun x tsc --noEmit→ exit 0;bun run lint(eslint) → exit 0