Skip to content

free the acp prompt slot before the response leaves - #3347

Merged
snimu merged 5 commits into
mainfrom
lane/acp-acomp-flake
Oct 5, 2026
Merged

snimu merged 5 commits into
mainfrom
lane/acp-acomp-flake

Conversation

@kevinjosethomas

@kevinjosethomas kevinjosethomas commented Oct 3, 2026 •

Copy link
Copy Markdown
Member
  • the acp turn settle that raced its prompt-slot clear behind the response (the ci-wave flake red-acp-auto-compaction-20261002-1, a stopReason-null red on the auto-compaction e2e) is gone with the single-daemon-path merge this branch folds; the daemon path already released the slot before replying, and this pr keeps that contract pinned.
  • a new e2e sends twenty back-to-back prompts so every settled turn must admit the next one, and the failing test now prints the full response envelope plus the turn-failure text on stderr when it fails.

Note

Low Risk
Changes are limited to e2e assertions and stderr logging on error paths; no production control-flow changes in the diff.

Overview
This PR pins the ACP contract that a settled turn must admit the next session/prompt immediately (no race where the slot stays held until after the JSON-RPC reply).

It adds acp_settled_prompt_immediately_admits_the_next_prompt, which runs 20 back-to-back prompts on one session and requires every response to have stopReason: end_turn, with a message that dumps the full envelope when admission races the settle.

Test ergonomics: a shared assert_end_turn helper replaces bare stopReason checks in the auto-compaction e2e so failures print the entire response (not just null when an internal_error path loses the failure text in the assertion).

Daemon diagnostics: on failed turns in prompt_turn, the handler now **eprintln!**s pa-daemon: acp turn failed: {failure} before returning the internal error, so harnesses that dump child stderr show the underlying worker failure.

Reviewed by Cursor Bugbot for commit 729f390. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Free the ACP prompt slot before the response leaves

  • Adds an assert_end_turn helper that checks a settled ACP response has an end_turn stop reason and prints the full response envelope on failure; reuses it in the compaction-meta test in acp_mode_e2e.rs
  • Adds an e2e test that sends 20 sequential prompts, issuing each next prompt immediately after the prior response, and requires every response to end with end_turn
  • Adds an stderr diagnostic in the acp.prompt_turn handler in daemon.rs that prints provider failure text with a pa-daemon: acp turn failed: prefix before returning the internal error

Macroscope summarized 729f390.

The ACP turn settle sends its response through the async FrameSink and
only then clears the connection's prompt slot: the writer task can put
the response on the wire while the turn task still waits on the
connection mutex, so a client that prompts again the instant it reads
the response races the slot clear and gets the still-set slot's 'A
prompt turn is already running' refusal — the CI-wave flake shape
behind acp_threshold_auto_compaction_publishes_the_compaction_meta's
second prompt (registered red-acp-auto-compaction-20261002-1, stopReason
null at acp_mode_e2e.rs:1729). Clear the slot before every settle-path
send, matching the daemon-attached path's release_turn_slot ordering.

The turn-failure text now also echoes to stderr (a stop-reason assert
loses the internal_error message), the failing test prints the whole
response envelope on mismatch, and a new test opens the admission
window on twenty sequential prompts.
@kevinjosethomas kevinjosethomas changed the title free the ACP prompt slot before the response leaves free the acp prompt slot before the response leaves Oct 3, 2026
Main's single-daemon-path migration (#3264) deleted the in-process ACP
transport whose settle raced its prompt-slot clear behind the response
(the flake this lane pinned): the surviving daemon path releases the
turn slot before the reply leaves, so the fix rides the merge and the
lane keeps the regression tests plus the settle-failure stderr echo on
the surviving path.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ae6b431. Configure here.

Comment thread crates/pa-cli/tests/acp_mode_e2e.rs Outdated
@snimu
snimu merged commit ae8f653 into main Oct 5, 2026
27 checks passed
@snimu
snimu deleted the lane/acp-acomp-flake branch October 5, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants