fix(subagents): report manually quit child sessions#53
Open
w-winter wants to merge 1 commit into
Open
Conversation
23fa69a to
e56bdf3
Compare
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.
Fixes a lifecycle gap where a Pi-backed child subagent could be manually quit while the parent kept treating it as still running. Graceful child shutdown now uses the existing
.exitsidecar protocol, so the watcher receives a terminal exit record and can clear parent-side state instead of relying on shell/screen sentinel behavior.I believe the issue originates in the initial
.exitsidecar design:subagent_doneandcaller_pingwrote terminal sidecars, but quitting the child session directly didn't. b4b0287 made that direct quit observable viasession_shutdown("quit"); this PR wires that event into the same terminal-exit contract.The implementation logic: child sessions classify their own exits as
done,ping,error, orquit, and the parent renders manual quit as "closed by user" rather than task completion or failure. The child-side sidecar claim is process-local and uses exclusive create semantics, so the first successful writer wins and later shutdown bookkeeping can't reclassify an already-claimeddone/ping/errorexit as a stale quit after the parent consumes the sidecar.Summary of changes:
.exitsidecar writer with atomic first-writer-wins semanticsdonefor normal auto-exit and preserveerror,ping, and explicitsubagent_donesidecarsquiton unclaimedsession_shutdown("quit")so manual child exits notify the parent{ type: "quit" }as a terminalquitreasonexitReasonthrough subagent completion, resume handling, result details, and renderingVerification:
npm test/node --test test/test.ts→ 138/138 passing (with a local-only patch for a confirmed-preexisting planner fixture mismatch)PI_TEST_MODEL=openai-codex/gpt-5.4-mini(I'm without Claude in Pi currently) → 15/15 passingauto-exit: falseworker, quit the child with/quit, and confirmed the parent emittedSub-agent "ManualQuitCheck" closed by user, not completed/failedclosed by userresultScreenshots: