feat(acp): preserve causal prompt correlation - #1239
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cbdff0b. Configure here.
| return true; | ||
| } | ||
| throw error; | ||
| } |
There was a problem hiding this comment.
Exact shutdown succeeds on missing socket
High Severity
The exact-shutdown catch treats any failure as success whenever existsSync(socketPath) is false. That is not a reliable “daemon gone” signal: Windows named pipes typically do not appear as files, and a refused unverified daemon still running after a handshake error is reported as stopped. Callers then skip shutdown and can proceed as if the process had exited.
Reviewed by Cursor Bugbot for commit cbdff0b. Configure here.


Stack
P2 child of #1236 only.
v080/acp-p1-final-core) atdc6f1a8a774f6295f4591e2f01422090b57fa83228b42c2eb3afc6b1881020a8d9c27fd6457bfb2d7f8ca486bfecc9039efbfcbd136ef5af56f730c3Parent-first integration is preserved by an append-only merge commit. Merge #1236 first, then retarget and finalize this PR.
Scope
Exact reviewed P2 causal correlation/lifecycle delta integrated with the final P1 head. Ten P2 paths only; no unrelated Core production duplication.
Verification
tsgo --noEmit: passedRLM_DEPTHandRLM_MAX_DEPTHscrubbedcacde7827aadf186db2ce1af1ea6f3b6d109504fa94945633bd9c0d96106b882The tracked fixture is commit-bound evidence, not the final distributable Prime Agent artifact. Final artifact creation, create-only publication, fetch-rehash, and fresh
PrimeAgentHarnessdry-load remain required after the stack is immutable.No live, paid, model, sandbox, or evaluation run was performed.
Note
High Risk
Large changes to ACP prompt lifecycle, terminal/cancellation semantics, and intercept retry/idempotency affect protocol consumers and paid inference paths; exact-socket shutdown touches rollout-owned daemons.
Overview
ACP session updates now go through a serialized
AcpUpdateProducerthat stamps everysession/updatewithpromptTurnId, monotoniceventSequence,phase(event/responseBoundary/terminalQuiescence), and optionaloutcomein_meta, instead of firing notifications ad hoc. Prompt turns emit a response boundary and, when no subagents remain, a terminal quiescence envelope withquiescencecounters; updates are buffered untilsession/newcommits on the wire, andsession/closedrains the queue before replying.Turn completion is driven by live child rosters:
getRlmChildSnapshots()on the session, snapshots includechildren, and the daemon connection mergesrlm_child_updateinto cached snapshots so quiescence is not inferred from stale attach data. Cancellation after a sealed terminal boundary no longer relabels the turn as cancelled.For the
interceptprovider, the agent loop injects a per-logical-requestX-Prime-Agent-Relay-IDheader (caller-supplied values stripped), andAgentSessionskips outer auto-retries so idempotency stays at the provider layer.CLI
shutdown --daemon-socket <path>shuts down only a verified same-build daemon viashutdownExactDaemonAndWait(no--force). Release packing skips__pycache__/.pycwhen copying.Reviewed by Cursor Bugbot for commit cbdff0b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add causal prompt correlation metadata to ACP session updates
AcpUpdateProducerin acp-mode.ts to serialize all outboundsession.updatenotifications and stamp them withpromptTurnId,eventSequence,phase(event/responseBoundary/terminalQuiescence), andoutcome(result/error) fields under a namespaced_metakey.responseBoundaryupdate followed by aterminalQuiescenceupdate (when no child subagents remain), and heartbeats are pinned to connection-scoped turn 0.session/newrejects concurrent admissions while a snapshot is in flight;session/closedrains the publish queue before returning; cancellation during a sealed terminal turn no longer relabels the stop reason.AgentSession.getRlmChildSnapshots()to expose a hierarchical live child-agent snapshot used for quiescence accounting.shutdownExactDaemonAndWaitto the CLI, allowingshutdown --daemon-socket <path>to stop only a verified matching daemon instance.interceptprovider models, each LLM streaming request now carries a uniqueX-Prime-Agent-Relay-IDheader, andAgentSessionno longer outer-retries intercept provider errors.session.updatenotifications will see new_metafields and a changed emission order (boundary then quiescence), which may break clients that do not tolerate unknown metadata.Macroscope summarized cbdff0b.