Skip to content

fix(acp): pair replay agent responses to concurrent requests in order - #42660

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
haiderking1:fix/replay-agent-concurrent-requests
Nov 25, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
haiderking1:fix/replay-agent-concurrent-requests

Conversation

@haiderking1

Copy link
Copy Markdown
Contributor

Requested in #42647 (comment) as a provider-neutral PR.

Summary

The ACP replay agent pairs response frames to pending client requests by method name, keeping one slot per method. When two requests of the same method are open at once, the second overwrites the first in that slot, so the first emitted response pairs with the wrong request and the second finds no pending request at all.

This shape is not exotic: steering a turn by prompt is a second session/prompt while the first still runs, which is how prompt-steering agents carry a turn over several prompts. No replay fixture could express it, so steering behavior cannot be covered through the replay harness today.

Responses now pair first-in-first-out per method, matching how agents answer prompts in order. Test-infra-only change; no production code and no provider-specific behavior involved.

How it was checked

The regression test drives the generic adapter through a replay fixture: a turn is steered mid-prompt, then two session/prompt responses arrive. In request order the first response (cancelled) settles the original, already-superseded prompt and the second (end_turn) settles the steer, ending the turn completed. If pairing is wrong the cancelled response lands on the steer instead and the turn dies with it, so the test observes pairing directly.

Without the fix:

AssertionError: expected 'cancelled' to equal 'completed'

With the fix the test passes, along with the full AcpAdapterV2.test.ts suite (162 tests) and vp run check:changed (format, lint, knip, typecheck, tests).

Test plan

  • failing test on main, passing with the fix
  • vp run check:changed clean

the replay agent paired response frames to client requests by method name
in a single slot, so a second concurrent request of the same method
overwrote the first and responses mis-paired or failed to pair at all.
a prompt steer is exactly that shape: a second session/prompt while the
first still runs, which no replay fixture could express.

responses now pair first-in-first-out per method. the regression test
steers an active turn through the generic adapter and asserts the turn
ends completed: mis-pairing the first response onto the steer settles it
as cancelled instead, so the test fails when pairing is wrong.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The replay agent now stores pending request IDs in FIFO queues by method and consumes one ID per response. A replay test covers response matching when steering starts a second concurrent session/prompt request.

Changes: ACP request response matching

Layer / File(s) Summary
Queue concurrent request IDs
apps/server/scripts/acp-replay-agent.ts, apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
The replay agent appends accepted request IDs to a per-method queue and removes the oldest ID when matching a response. The replay test checks response ordering for concurrent prompts during steering.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#41320: The issue describes a second session/prompt request during steering while the first remains open. This PR tests the response matching for that scenario, but does not change the reported timeline folding behavior.

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Minimal · up to c390e

Merge Risk: ⚪ Minimal · up to c390e

This change fixes how the test replay agent pairs concurrent responses and adds a regression test for steering during an active prompt. It has no production impact, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(acp): pair replay agent responses to concurrent requests in order" matches the main change. The raw summary says pendingClientRequestIds becomes a FIFO queue per method, so responses pa…
Description check Passed The description covers the problem, the change, scope, and verification. The Problem section is explained in the Summary. The Change section explains FIFO pairing per method. The Scope section says th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(acp): pair replay agent responses to concurrent requests in order" matches the main change. The raw summary says pendingClientRequestIds becomes a FIFO queue per method, so responses pair in request order for concurrent requests. The title is specific and follows conventional commit style. It is a short, single sentence.

Full details: Description check

Explanation

The description covers the problem, the change, scope, and verification. The Problem section is explained in the Summary. The Change section explains FIFO pairing per method. The Scope section says this is a test-infrastructure-only fix, but it does not link an issue that shows the bug. It cites a maintainer request through the PR comment link, which the template asks for. The Verification section lists the failing test output, the 162-test suite, and the check run. The description does not have the explicit template headings (Problem, Change, Scope, Verification), and it has no agent/model line at the end. These gaps are minor. The description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c6c8b20 and 87713e8.

Files selected for processing: 2

  • apps/server/scripts/acp-replay-agent.ts
  • apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 25, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Ran the actual replay-agent command on Linux, Node v26.13.1, using identical fresh synthetic transcripts. Sent prompt id 3, then steer id 4 after 500 ms; replayed cancelled, message chunk, then end_turn.

Before After
c6c8b20566 c390eccd81
Before: cancelled incorrectly resolves id 4; missing pending request; exit 1 After: cancelled resolves id 3; end_turn resolves id 4; exit 0
Before recording After recording

The visuals render timestamped subprocess output, not app-screen recordings. Base stops at 4/5 entries with exit 1; head completes 5/5 with exit 0.

Driver, transcript, before raw capture, after raw capture, capture renderer. Evidence uploaded using the ghdrop skill.

Not shown:

  • Adapter steerTurn terminal status and web-client behavior were not exercised. This proves the reported replay-command request-pairing defect directly; it does not establish the downstream UI outcome.
  • No scenario was run: the scenario guidance excludes provider protocol behavior, and this reproduction directly drives the replay helper's JSON-RPC interface.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 25, 2026
@juliusmarminge
juliusmarminge merged commit 7dc7b29 into pingdotgg:main Nov 25, 2026
17 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants