feat(acp): preserve causal prompt correlation - #1239
Open
sethkarten wants to merge 33 commits into
Open
Conversation
7 tasks
sethkarten
marked this pull request as ready for review
August 12, 2026 06:18
This was referenced Aug 14, 2026
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 c2c5000. Configure here.
alexzhang13
approved these changes
Aug 17, 2026
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.

Summary
session/updatepublication and attach causalpromptTurnIdand monotoniceventSequencemetadataStack
dc6f1a8a774f6295f4591e2f01422090b57fa832cbdff0bd8072a65934d60780c5a896f9e5a1b320Merge #1236 first, then retarget this PR to
mainand merge it second.Protocol contract
The new correlation fields are additive metadata under
_meta.eventSequenceis connection-wide and strictly increasing. A scoreable terminal envelope is emitted only after authoritative child-lifecycle quiescence; cancellation cannot relabel an already sealed terminal pair.Validation
Note
High Risk
ACP prompt correlation, terminal sealing, and quiescence semantics are easy for clients to misread if any publish path regresses; exact-socket shutdown and intercept no-retry boundaries also touch operational safety and request idempotency.
Overview
This PR tightens ACP client correlation and several lifecycle boundaries around prompts, children, and daemon rollouts.
ACP now routes all
session/updatetraffic throughAcpUpdateProducer, which serializes publication and stampspromptTurnId, monotoniceventSequence,phase(event/responseBoundary/terminalQuiescence), andoutcomeon_meta. Updates are buffered untilsession/new’s JSON-RPC response is on the wire; each prompt ends with a response boundary plus a quiescence envelope (outstanding subagents, remaining autonomous continuations) when work is truly terminal. Child updates stay tied to their origin turn (or turn0after seal), and cancellation cannot relabel a sealed terminal pair.RLM snapshots add
getRlmChildSnapshots()(live registry + retained sessions, including nested/hidden-delete cases) and feedchildrenon connection snapshots; the daemon connection patches the cached roster onrlm_child_update.Intercept / retry: the agent loop injects a fresh, caller-overwritable
X-Prime-Agent-Relay-IDper intercept completion;AgentSessionskips outer auto-retry (and related auth-retry paths) forinterceptso idempotency stays at the provider layer.CLI:
shutdown --daemon-socket <path>callsshutdownExactDaemonAndWait, which shuts down only a verified same-build daemon at that path (no--force).Smaller fixes: test teardown waits on child processes / retries
ENOTEMPTYcleanup; release packing skips__pycache__/.pyc.Reviewed by Cursor Bugbot for commit a6f6d52. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add causal prompt correlation and event sequencing to ACP session updates
AcpUpdateProducerin acp-mode.ts to serialize ACP session updates with strictly increasingeventSequenceandpromptTurnId, correlating child agent updates to their origin prompt turn.phase(event,responseBoundary,terminalQuiescence) andoutcome(result|error) fields toPrimeAgentSessionMetain acp-meta.ts to annotate each update's causal role.session/newresponse is written to the transport, preventing out-of-order delivery.outstandingSubagentsandremainingAutonomousContinuationscounters.X-Prime-Agent-Relay-IDheader (32-char hex) for intercept providers, preventing auto-retry on auth failures from the intercept provider.shutdownExactDaemonAndWaitto verify daemon build identity before issuing shutdown, and exposes it via theshutdown --daemon-socketCLI flag.session/closenow halts update admission before draining, preventing post-close boundary publications; cancellation no longer relabels a durable boundary/terminal pair.Macroscope summarized a6f6d52.