GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(session): spawn subagent sessions and wait for their answer by kitlangton · Pull Request #62036 · anomalyco/opencode

Conversation

@kitlangton

@kitlangton kitlangton commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Clients can now start a subagent session with one call and wait for its answer.
A new experimental spawn endpoint creates a child of a session, records whether the parent wants a report, and can send the child's first prompt. session.wait now 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/spawn with { id?, notify?, agent?, model?, title?, prompt? } and get the child's id back. Pass your own id to make a retry safe: the same id returns the same child instead of a second one.
  • POST /api/experimental/session/:id/wait returns { 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.
  • In core, Session.spawn({ parent: { id, notify }, … }) does the same.

🚦 How it ships: both endpoints stay under /api/experimental. Creating a child with parentID on create still works but is marked deprecated in favor of spawn.

- create({ parentID }) -> prompt(child) -> wait(child): void -> read messages -> find answer
+ spawn({ parent: { id, notify }, prompt }) -> wait(child): { outcome, text }

📊 Proof

Check Result
core session-wait, session-create, subagent-lifetime 90 pass, 2 fail (see below)
server session-create 7 pass
client effect, promise 50 pass

The new tests cover spawn inheriting location, metadata and permissions from the parent, the retry with a caller-chosen id, notify reaching the child, and wait finding an answer older than the newest 20 messages. The two local failures are the existing session.shell tests in session-create, which time out on my machine on the bottom PR too, where session.ts is unchanged from dev; CI is the judge for those.

↩️ Undo: session.wait changed 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 extracted createChild, which both create-with-parent and spawn now use; check that inheritance and the existing-ID path match the old branch. And Session.wait in session/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, 2 session.shell timeouts
  • bun test test/session-create.test.ts test/session-wait.test.ts (packages/server): 7 pass
  • bun test test/effect.test.ts test/promise.test.ts (packages/client): 50 pass

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kitlangton
kitlangton requested review from Brendonovich and Hona as code owners November 5, 2026 09:35
@github-actions github-actions Bot added the contributor label Nov 5, 2026
@kitlangton kitlangton mentioned this pull request Nov 5, 2026
feat(core): subagents report to their parent every time they finish #61833
Closed
kitlangton added 7 commits November 5, 2026 01:59
@kitlangton
feat(core): add Session.spawn for subagent children
e6aef1e
@kitlangton
feat(core): return outcome and text from Session.wait
f2b0727
@kitlangton
feat(session): add experimental spawn endpoint and typed wait result
e3f4afc
@kitlangton
feat(core): make Session.spawn safe to retry with a caller-chosen id
9b2833b
@kitlangton
feat(core): page Session.wait back through history for an answer
114189e
@kitlangton
feat(protocol): accept client-chosen id in session.spawn
8b99133
@kitlangton
test(core): use Effect.andThen in session wait mock
f23941d
@kitlangton
kitlangton force-pushed the pool-subagents-background branch from c9b3b28 to d690980 Compare November 5, 2026 10:03
@kitlangton
kitlangton force-pushed the pool-subagents-spawn branch from 3d9759c to f23941d Compare November 5, 2026 10:03

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Hona Hona Awaiting requested review from Hona Hona is a code owner
@Brendonovich Brendonovich Awaiting requested review from Brendonovich Brendonovich is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@kitlangton
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.