Repository navigation
feat(session): spawn subagent sessions and wait for their answer - #62036
Open
kitlangton wants to merge 7 commits into
Open
kitlangton wants to merge 7 commits into
kitlangton wants to merge 7 commits into
Conversation
kitlangton
force-pushed
the
pool-subagents-background
branch
from
November 5, 2026 10:03
c9b3b28 to
d690980
Compare
kitlangton
force-pushed
the
pool-subagents-spawn
branch
from
November 5, 2026 10:03
3d9759c to
f23941d
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.
Clients can now start a subagent session with one call and wait for its answer.
A new experimental
spawnendpoint creates a child of a session, records whether the parent wants a report, and can send the child's first prompt.session.waitnow returns how the child's last run ended and its final answer, instead of nothing.Stacked on #62035 (background by default), which is stacked on #61833. Part 3 of 3.
💡 Why
Today a client that wants a subagent has to create a session with
parentID, prompt it, wait, then read its messages to find the answer. Plugins and the SDK kept re-implementing that, and none of them could say "don't report back to the parent".🆕 Now you can
POST /api/experimental/session/:id/spawnwith{ id?, notify?, agent?, model?, title?, prompt? }and get the child'sidback. Pass your ownidto make a retry safe: the sameidreturns the same child instead of a second one.POST /api/experimental/session/:id/waitreturns{ outcome, text }: the last run's outcome and the newest completed, error-free assistant answer, paging back through the whole history rather than only the newest 20 messages.Session.spawn({ parent: { id, notify }, … })does the same.🚦 How it ships: both endpoints stay under
/api/experimental. Creating a child withparentIDon create still works but is marked deprecated in favor of spawn.📊 Proof
session-wait,session-create,subagent-lifetimesession-createeffect,promiseThe new tests cover spawn inheriting location, metadata and permissions from the parent, the retry with a caller-chosen
id,notifyreaching the child, and wait finding an answer older than the newest 20 messages. The two local failures are the existingsession.shelltests insession-create, which time out on my machine on the bottom PR too, wheresession.tsis unchanged fromdev; CI is the judge for those.↩️ Undo:
session.waitchanged from an empty 204 to a JSON body. A client generated before this PR rejects the new response, and a new client rejects an old server's 204, so revert the regenerated clients together with the server. The endpoint is under/api/experimental, and the CLI and TUI ship with the server, so only third-party callers of the experimental route see the change.👀 Read:
packages/core/src/session.ts, the extractedcreateChild, which both create-with-parent and spawn now use; check that inheritance and the existing-ID path match the old branch. AndSession.waitinsession/session.ts, which re-reads the session after idle so it doesn't return the previous run's outcome. The rest is routine.From a team design discussion · no user reports · reviewed before push
Checks run
bun test test/session-wait.test.ts test/session-create.test.ts test/subagent-lifetime.test.ts(packages/core): 90 pass, 2session.shelltimeoutsbun test test/session-create.test.ts test/session-wait.test.ts(packages/server): 7 passbun test test/effect.test.ts test/promise.test.ts(packages/client): 50 pass