fix(subagents): keep print-host parents from settling without wait - #515
fix(subagents): keep print-host parents from settling without wait#515tt-a1i wants to merge 2 commits into
Conversation
--print/--json cannot re-invoke after agent_settled, so spawn text that tells the model to end the turn drops required child results. Require subagent_wait on non-TUI hosts and send a bounded follow-up barrier.
Correct E-06..10 as pre-fix, point at bun/unit logs and hang issue #516, and keep the reliability notes from being read as a Benchmark.
tt-a1i
left a comment
There was a problem hiding this comment.
Self-review at exact head a10103d. I cannot formally request changes on a PR authored by this account, but the following are merge-blocking.
Standards
[P1] Print-host completion is still prompt-enforced rather than runtime-enforced. The agent_settled handler injects at most two “MUST call subagent_wait” follow-ups and then allows settlement while children may still run. The 10/10 experiment validates that the improved spawn wording influences this model; it does not establish a fail-closed lifecycle barrier.
[P1] runningDirectIds duplicates manager lifecycle state and misses valid transitions. A fast child can settle before the ID is added after spawn, leaving a stale running ID; a settled child restarted through subagent_send is never re-added. Please derive this state from the manager rather than maintaining a parallel Set.
Spec
[P1] Restarted direct children receive neither print-host wait guidance nor barrier tracking, so their required result can still be lost when the parent exits.
[P1] The fallback calls fire-and-forget pi.sendMessage() from agent_settled. Pi print mode can finish the original prompt and dispose before that nested turn completes; current tests assert pure helpers and the experiment runs all obeyed the earlier spawn guidance, so the fallback path has no end-to-end evidence.
[P2] The barrier counter is Session-global and never resets per spawn/batch, and RPC is included without protocol-level validation. The draft research records are also indexed under “Validated investigations.”
Summary
--print/--mode jsoncannot re-invoke the parent afteragent_settled. Stock spawn text still tells the model it may end the turn; required child results are lost (E high-fast 3/10 print-settle failures).subagent_wait, plus a boundedfollowUp+triggerTurnbarrier if the parent settles while direct children are running. Interactive TUI guidance is unchanged.cursor-grok-4.6-high-fast: 7/10 before (v0.8.1 stock) → 10/10 after. Isolatedbun run checkandbun run testpass. Closes nothing; tracks bug(subagents): --print/--json parent can settle while required children are still running [under investigation] #512. Do not merge from this reliability session unless a maintainer asks.Test plan
tests/extensions/subagents/print-host.test.tsand prompt contractbun run check&&bun run testin isolated v0.8.1 worktree