Repository navigation
print mode (-p) aborts in-flight rlm.spawn() children instead of waiting for them #2270
Replies: 2 comments
|
Investigated this report and produced a candidate fix, validated on a fork of this repository. Root cause, fix and validation from the working notes:
Diff: awhite0030/prime-agent@main...fix-2270-print-mode-wait-rlm-5064527283883454858 The change passes |
|
I just hit this issue now, running in -p mode "I've dispatched all 5 workers and they're converting the integration test files in parallel. I'll consolidate their results as they report back. Ending my turn to let them work." Then instantly terminates the subagents. Took me a while to get to the conclusion it was prime-agent terminating itself (I was checking for out of memory or context space issues that could be causing errors) I'd personally love this to be merged in as it's a breaking issue for my workflow. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Bug:
-p(print mode) aborts in-flightrlm.spawn()children instead of waiting for themSummary
A parent session that spawns child subagents via
rlm.spawn()and ends its turn — the documented, expected pattern — has its process torn down the moment the parent's own turn goes idle, if invoked through-p(print mode). Any children still in flight get aborted before they can send theiragent_messagereply, so the parent never receives their reports.Root cause
packages/coding-agent/src/modes/print-mode.tscalls:with no options.
waitForHeadlessCompletion()(packages/coding-agent/src/modes/headless-completion.ts) takes awaitForRlmQuiescence?: booleanoption specifically to choose between:session.waitForHeadlessIdle()— waits only for the parent's own turn/compaction to settle (no descendant awareness), orsession.waitForRlmQuiescence()— "Wait for every admitted descendant run to publish its terminal parent message and for the resulting parent turns to drain" (agent-session.ts).Since print mode never passes
{ waitForRlmQuiescence: true }, it always takes the first path. This is inconsistent with the rest of the codebase —acp-mode.ts'sfinalizePendingTerminalpath explicitly passes{ waitForRlmQuiescence: true }for exactly this reason, anddaemon-mode.ts's RPC handler exposes it as a caller-controlled parameter. Print mode is the one entry point missing it.Reproduction
Observed:
~/.prime/agent/session-artifacts/<parent>/sub-*/rlm-subagent.jsonand each child's own session.jsonl: all three children reach"status": "completed", but each was aborted (stopReason: "aborted", errorMessage: "Request was aborted") right after reading its assigned file and before ever callingagent_message.send.[child-exited: no-reply]custom message (kind: "completed_without_reply") for at least one child.Fix (verified locally)
Re-ran the exact repro after this change: all three children reach
agent_message.send(confirmed in each child's own transcript), zero abort/no-reply notices, and the parent produces the actual consolidated report combining all three subagent findings.npm run check(biome + tsgo + installer check + browser smoke) passes clean with the change.Environment
mainbranchmodels.json(not provider-specific — root cause is in the completion-wait logic, unrelated to any provider)Happy to open a PR with this one-line fix + a regression test if a maintainer wants it — keeping this to a Discussion first per
CONTRIBUTING.md.All reactions