Repository navigation
fix(acp): recover terminal reply and surface run errors on reconnect reconcile - #126909
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 6:09 AM ET / 10:09 UTC. ClawSweeper reviewWhat this changesThis PR recovers Gateway terminal replies after ACP reconnects, records them for replay, and rejects failed runs instead of reporting clean completion. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer review: current main still drops terminal reply evidence during ACP reconnect reconciliation, while this PR repairs that owner boundary without a concrete new correctness finding. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe ACP bridge forwards client prompts to the Gateway and tracks each pending prompt locally. After reconnecting, it queries the Gateway’s terminal result, emits replayable ACP updates, and settles the client prompt. flowchart LR
A[ACP client prompt] --> B[ACP bridge pending prompt]
B --> C[Gateway agent run]
C --> D[Terminal run result]
D --> E[Reconnect reconciliation]
E --> F[Ledger and ACP updates]
F --> G[Resolved or rejected prompt]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +75, Tests +685. Total +760 across 5 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one ACP prompt-owner settlement path that claims first, records the recovered reply or suffix, then resolves or rejects according to Gateway terminal status. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s reconcile branch visibly omits terminalReply and turns error results into end_turn; the branch adds focused boundary scenarios for those outcomes. Is this the best way to solve the issue? Yes. Gateway already owns sanitized terminal reply evidence, and replay plus settlement belong in the ACP prompt owner rather than a second transcript-replay path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 83e7fa19552f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review Both P1 findings are addressed on Finding 1 — terminal suffix after partial streaming: the recovery branch in Finding 2 — settlement on delivery failure: recovered chunks now go through Proof: new regression tests live in |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Round 3 pushed (
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Round 4 pushed ( |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Real ACP/Gateway reconnect proof added to the PR body (same reviewed head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Addressed the P1 finding ("Recover terminal replies returned with timeout status") on head Change: reconnect reconciliation now routes a sticky
Regression: Red proof: with the two production hunks stashed, the new test fails (prompt never settles; suite times out) — with them applied it passes. Local runs on this head: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
b4b4374 to
0dc2a2e
Compare
|
Addressed the P1 finding ("Recover visible terminal replies on error results") on head Change: Regressions (both fail on the previous head, pass here): error+reply replayed before interruption+rejection; error+reply with a streamed prefix recovers only the suffix. Red proof: production hunk stashed → both new tests fail; applied → Real behavior proof on this exact head added to the PR body — three real-process ACP/Gateway reconnect scenarios (TCP proxy cut/resume, real
Also noted in the body: the sticky @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: wangmiao0668000666 <[email protected]>
0dc2a2e to
d0c6973
Compare
|
Thanks @wangmiao0668000666! Proof: I ran the same real built Gateway, ACP bridge, and ACP client through a bridge-to-Gateway disconnect on current main and this exact head. Two changed reply payloads were both lost on main and each arrived exactly once after reconnect on this head. A real run timeout resolved as a normal turn on main; this head emitted the interruption and rejected the prompt. Exact-head CI passed 138 checks, and local ClawSweeper passed at platinum tier B with no findings, security concerns, owner decisions, or Rank-up moves.
The older public Rank-up moves are complete: exact-head merge checks passed, and ordinary maintainer review is complete. The queued public review refresh does not replace the exact-head local gate. Example
|
|
Thank you @obviyus! Really appreciate the thorough review — especially the real bridge-to-Gateway disconnect proof you ran on both main and this head. Verifying the payloads were lost before and arrived exactly once after reconnect is exactly the behavior that mattered here. 🙏 |
ACP reconnect settlement discarded the Gateway-owned terminal reply and treated failed runs as normal turns. Recover the missing reply exactly once before settling from the real terminal status. Keep the recovered chunk durable for session replay and preserve error rejection. Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #126903
What Problem This Solves
When the Gateway connection dropped during an ACP prompt, the run could finish while the bridge was disconnected. Reconnect reconciliation then resolved the prompt without delivering the terminal reply. A failed run also resolved as a normal
end_turn.Why This Change Was Made
agent.waitalready returns the producer-owned, boundedterminalReply. The ACP reconnect path discarded that fact and mappedstatus: "error"to normal completion.The prompt owner now claims the pending prompt before any recovered delivery can await. It records and emits the full missing reply or suffix once, then applies the real terminal status: success resolves and failure emits an interruption before rejecting. Normal streamed chunks and recovered chunks use one emission path.
User Impact
ACP clients no longer lose replies that finish during a short Gateway disconnect. They also see failed reconnect-settled runs as failures instead of successful turns.
Evidence
Real Gateway red/green proof
The same process-level scenario ran on the exact
origin/mainrevision at proof time,9022e0e1cf3f1933b9fd41b4a95256bfaf1eedf0, and exact headd0c6973c8c1137bfa0b7d06c57cdf836351eb232:@agentclientprotocol/sdkclient over stdio.agent.waitterminal state before the proxy resumed.end_turnend_turnend_turnend_turnstatus: "error", ACP delivered no interruption, prompt resolvedend_turnThe alpha-to-beta payload change is the anti-replay probe. Each head scenario recorded the exact run ID, disconnect, terminal observation, reconnect, ACP update, and settlement order in retained private evidence.
Regression and local checks
node scripts/run-vitest.mjs src/acp/translator.disconnects.test.ts -t 'full reply'fails because no recovered chunk exists.node scripts/run-vitest.mjs src/acp/translator.disconnects.test.ts src/acp/translator.stop-reason.test.ts src/acp/translator.session-updates.test.ts src/acp/translator.final-snapshots.test.tspasses 33 tests.node scripts/run-vitest.mjs src/acppasses 71 files and 600 tests.git diff --checkpass.Change Size
Co-authored-by: wangmiao0668000666 [email protected]