Repository navigation
fix: workers wait for their own subagents before ending (#388) - #411
Merged
rochecompaan merged 6 commits intoNov 22, 2026
Merged
rochecompaan merged 6 commits into
rochecompaan merged 6 commits into
Conversation
rochecompaan
marked this pull request as ready for review
November 22, 2026 15:15
rochecompaan
deleted the
agent/issue-388-implementation-worker-ends-without-a-result-whil
branch
November 22, 2026 15:20
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.
Closes #388
A worker now waits for its own subagent runs in the same turn, the Console agent never tells it to yield, and a
no resultoutcome names a run that was still running.Changes
src/kernel/unfinished-runs.ts(new): reads the worker's own session JSONL and lists subagent runs it started or resumed and never saw finish (subagent-notify,bg_waitcompletion, orstop). Entries copied from before a fork, child sessions in subdirectories, and broken lines are ignored.src/kernel/run-once.ts: after a phase session that did not time out or abort, ano resultreason becomes e.g.no result: the worker ended its turn while its reviewer run <id> was still running. Status staysinvalid, label staysneeds-info.src/cli/commands/init/agent-dir.ts: the console worker getsbg_waitandsubagent_supervisor.skills/patchmill-implementation/SKILL.md: new "Wait for your own subagents" section; the reviewer launches withasync: trueand is awaited withbg_wait. Documents theresumeworkaround: a top-levelresumealways detaches (documented pi-subagents 0.80.0 behavior), so wait on its new run id withbg_wait.skills/patchmill-frontend-review/SKILL.md: same reviewer launch rule (review finding).src/kernel/run-envelope.md,envelope.ts: new hard rule for all envelopes except interactive planning.src/console/tools.ts: Console agent prompt guidelines: never tell a worker to yield or end without its result; tell it to wait withbg_wait.skills update.Rulings (cost if wrong)
async: false; changed toasync: true+bg_wait— cost: none beyond prose.skills updatealso moved manifest sourcepatchmill1.0.0 → 1.1.0 (package version) andinstalledAt— cost: none.status,bg_waiterror with completions, empty-runs notify, comment trust boundary, stop by id prefix, RPC tool registration) — all accepted as out of scope or unreachable; at worst they affect diagnostic wording.Deferred Minor findings
bg_waitrule (plan forbade text-assertion tests).Validation
npm test: 1656 pass, 0 fail (baseline 1639 pass, 0 fail)npm run lint: passnpm run build: passFrontend review
Not applicable: no browser-visible change (kernel, skills, prompts only).
Human Reviewer Callouts (Non-Blocking)
bg_waitandsubagent_supervisor(src/cli/commands/init/agent-dir.ts:24). Existing repositories pick this up at the next console or Web session start, without a newpatchmill init.no resultcan now have a cause after the prefix (no result: the worker ended …). Anything that reads it, such as the planned Recover when an implementation worker finishes without its result block #407 re-prompt, must match theno resultprefix rather than the whole reason..patchmill/skills/patchmill-skill-pack.jsonrecords sourcepatchmill1.0.0 → 1.1.0 and a newinstalledAt, as a side effect ofskills update.Patchmill run cost
Includes all retained local runs for this issue, including specification and planning PRs. Prompt tokens include uncached input, cache reads, and cache writes. Estimated cost uses Pi's recorded model pricing and includes parent and subagent sessions.