fix: auto-close spawned children on completion; subagent shutdown ordering - #849
Merged
Conversation
…ering - spawn_session tool now defaults autoClose=true; plumbed through POST /api/runners/spawn -> new_session -> spawner env, so completed child workers self-terminate instead of idling on the runner forever (auto-close remains guarded against pending messages/subscriptions). - Register subagentExtension before remoteExtension in factories so session_shutdown aborts in-flight relay mirrors and ends those child sessions before the remote extension disconnects the worker socket. - Docs: document the autoClose param.
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
Spawned child sessions had two lifecycle bugs:
spawn_sessionchildren never exited.PIZZAPI_WORKER_AUTO_CLOSEwas only plumbed through the trigger-listener routes — the/api/runners/spawnpath used byspawn_sessionnever set it, so every spawned child idled on the runner forever after finishing its task. Killing the parent didn't help: children are independent worker processes by design.subagentExtensionregistered afterremoteExtension, so onsession_shutdownthe remote extension disconnected the worker socket before the subagent extension could abort in-flight relay mirrors and end those ephemeral child sessions — leaving linked children showing as alive until the 10-minute ephemeral TTL sweep.Closes the shutdown-ordering half of Godmother idea
jj0WhkKm.Changes
spawn_sessiontool: newautoCloseparam, defaulttrue. Plumbed throughPOST /api/runners/spawn→new_session→ spawner env (PIZZAPI_WORKER_AUTO_CLOSE). Completed children now self-terminate instead of idling on the runner. The existing auto-close guard still applies — it won't close if new messages, subscriptions, or linked children arrive, andautoClose: falseopts out for interactive follow-ups.factories.ts: registersubagentExtensionbeforeremoteExtensionso shutdown aborts mirrors and ends their relay sessions before the worker socket disconnects.autoClosedocumented infeatures/multi-agent.mdx.Not in scope
Silent parent-link drop when the parent's Redis record is missing at child registration (child then renders top-level in the UI) — captured as Godmother idea
ZwI6GkdP.Testing
bun run typecheckclean.spawn_sessionautoClose plumbing tests (default true, explicit false).extensions/ + routes/batch has 7 pre-existing cross-file pollution failures reproduced identically on cleanorigin/main.