Skip to content

fix(acp): recover terminal reply and surface run errors on reconnect reconcile - #126909

Merged
obviyus merged 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/acp-reconcile-reply-recovery
Aug 28, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/acp-reconcile-reply-recovery

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

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.wait already returns the producer-owned, bounded terminalReply. The ACP reconnect path discarded that fact and mapped status: "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/main revision at proof time, 9022e0e1cf3f1933b9fd41b4a95256bfaf1eedf0, and exact head d0c6973c8c1137bfa0b7d06c57cdf836351eb232:

  • Real built Gateway with isolated state and token auth.
  • Real built ACP bridge and @agentclientprotocol/sdk client over stdio.
  • A WebSocket proxy cut the bridge-to-Gateway connection after model admission.
  • The run reached agent.wait terminal state before the proxy resumed.
  • Only the model endpoint was controlled so the reply could finish during the disconnect.
Scenario Current main This head
Reply marker alpha Gateway terminal reply changed, ACP delivered 0 copies, prompt resolved end_turn ACP delivered 1 copy after reconnect, prompt resolved end_turn
Reply marker beta Gateway terminal reply changed again, ACP delivered 0 copies, prompt resolved end_turn ACP delivered 1 changed copy after reconnect, prompt resolved end_turn
Real run timeout Gateway returned status: "error", ACP delivered no interruption, prompt resolved end_turn ACP delivered the interruption and rejected the prompt

The 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

  • Pre-fix regression: node scripts/run-vitest.mjs src/acp/translator.disconnects.test.ts -t 'full reply' fails because no recovered chunk exists.
  • Head regression: 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.ts passes 33 tests.
  • Full ACP suite: node scripts/run-vitest.mjs src/acp passes 71 files and 600 tests.
  • Scoped Oxfmt, Oxlint, selected repository ratchets, and git diff --check pass.
  • Falc0n did not run build or TypeScript type checks. The isolated proof host built both exact revisions; hosted CI owns final type checks.

Change Size

  • Production: +80/-56, net +24.
  • Tests: +204/-0.
  • The production growth is the reconnect settlement capability. Shared chunk emission and removal of duplicate text-length state absorb the rest of the contributor patch, reducing its production delta from net +75.

Co-authored-by: wangmiao0668000666 [email protected]

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 21, 2026
@wangmiao0668000666
wangmiao0668000666 marked this pull request as ready for review August 21, 2026 00:34
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 21, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 6:09 AM ET / 10:09 UTC.

ClawSweeper review

What this changes

This PR recovers Gateway terminal replies after ACP reconnects, records them for replay, and rejects failed runs instead of reporting clean completion.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep 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
Reviewed head: 0dc2a2ec505e5275184cab18ab66f7423b84846c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong real-process proof and focused contract coverage support a mergeable repair, subject to normal review of ordering-sensitive behavior.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The PR body includes an exact-head real Gateway, ACP bridge, and ACP client reconnect transcript with injected transport loss and observed after-fix recovery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR body includes an exact-head real Gateway, ACP bridge, and ACP client reconnect transcript with injected transport loss and observed after-fix recovery.
Evidence reviewed 6 items Current-main defect: Current main settles an ok result without reading terminal reply evidence and settles an error as end_turn, so the reported ACP behavior remains unfixed.
Gateway contract: Gateway agent.wait returns the terminal snapshot, including terminalReply, to its caller.
Sticky-timeout contract: Current Gateway tests prove visible terminal reply evidence is retained even when timeout remains the canonical status.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw acp --help

Result: PASS (completed)

pnpm openclaw acp --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-126909-zxkjxm/target$ pnpm openclaw acp --help
$ node scripts/run-node.mjs acp --help
pnpm openclaw acp --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 104.02 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 13.6s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4242ms (slowest: built plugin control-plane loads 3506ms)
│
◇

OpenClaw 2026.8.1 (0dc2a2e) — All your chats, one OpenClaw.

Usage: openclaw acp [options] [command]

Run an ACP bridge backed by the Gateway

Options:
  -h, --help               Display help for command
  --no-prefix-cwd          Do not prefix prompts with the working directory
  --password ‹password›    Gateway password (if required)
  --password-file ‹path›   Read gateway password from file
  --provenance ‹mode›      ACP provenance mode: off, meta, or meta+rec
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw acp

How this fits together

The 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]
Loading

Before merge

  • Resolve merge risk (P1) - The repair changes reconnect-time message delivery and prompt settlement ordering; its 75 net production lines are justified by the single claim-before-recording owner boundary, but deserve exact-head merge-gate review.
  • Complete next step (P2) - No discrete repair remains for automation; this PR already owns the focused fix and needs ordinary maintainer review.
Agent review details

Security

None.

PR surface

Source +75, Tests +685. Total +760 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 90 15 +75
Tests 2 685 0 +685
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 775 15 +760

Review metrics

Metric Value Why it matters
Production versus regression coverage production +90/-15 (net +75); tests +685/-0 The added production flow centralizes ordering-sensitive replay and settlement; tests cover its status, suffix, delivery-failure, and race boundaries.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #126903
Summary: This PR is the explicitly linked candidate repair for the ACP reconnect report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Retain the prompt-owner settlement path (recommended)
    Merge only after the exact-head gate confirms that the claimed-prompt ordering continues to preserve recovered delivery and single settlement.

Technical review

Best 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.

Labels

Label justifications:

  • P1: A Gateway reconnect can otherwise silently hide an active ACP prompt’s terminal reply or failure.
  • merge-risk: 🚨 message-delivery: The branch changes when recovered assistant text is emitted and recorded for ACP clients.
  • merge-risk: 🚨 session-state: The branch changes pending-prompt claiming and terminal settlement during reconnect races.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body includes an exact-head real Gateway, ACP bridge, and ACP client reconnect transcript with injected transport loss and observed after-fix recovery.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes an exact-head real Gateway, ACP bridge, and ACP client reconnect transcript with injected transport loss and observed after-fix recovery.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Available history associates the translator split with the ACP owner surface. (role: ACP refactor author; confidence: medium; commits: 7cf4f9aa6a3d; files: src/acp/translator.prompt-stream.ts, src/acp/translator.disconnects.ts)
  • Mohammed Alkindi: Current-main blame attributes the returned terminal result surface to this commit in the available checkout history. (role: recent Gateway wait-path contributor; confidence: medium; commits: 55cd6fe931b9; files: src/gateway/agent-turn/agent-turn-service.ts, src/gateway/agent-turn/agent-job.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-21T10:03:51.551Z sha c5c23d25174c5af35284f2258cec16bc88bace33 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T12:49:55.037Z sha c5c23d25174c5af35284f2258cec16bc88bace33 :: needs changes before merge. :: [P1] Recover terminal replies returned with a timeout result
  • reviewed 2026-08-22T13:32:02.440Z sha c5c23d25174c5af35284f2258cec16bc88bace33 :: needs changes before merge. :: [P1] Recover terminal replies returned with timeout status
  • reviewed 2026-08-22T15:29:31.868Z sha b4b4374e06244f7636c0fa3a90ab9cbf730e6836 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-22T16:13:11.241Z sha b4b4374e06244f7636c0fa3a90ab9cbf730e6836 :: needs real behavior proof before merge. :: [P1] Recover visible terminal replies on error results
  • reviewed 2026-08-23T02:44:32.221Z sha 0dc2a2ec505e5275184cab18ab66f7423b84846c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-23T03:42:37.394Z sha 0dc2a2ec505e5275184cab18ab66f7423b84846c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-24T05:16:36.438Z sha 0dc2a2ec505e5275184cab18ab66f7423b84846c :: needs maintainer review before merge. :: none

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Both P1 findings are addressed on 4b935e7b122 (details in the new "Round 2" section of the PR body).

Finding 1 — terminal suffix after partial streaming: the recovery branch in translator.disconnects.ts no longer drops the terminal reply when a prefix already streamed. If the terminal reply starts with the delivered sentText, only the missing suffix is emitted (e.g. streamed final + terminal final answer → emits answer); if it does not extend the prefix, emission stays suppressed to avoid duplicates.

Finding 2 — settlement on delivery failure: recovered chunks now go through sessionUpdates.emit with waitForDelivery: false (the same non-blocking recorded delivery the disconnect-notice path uses), so a rejected ACP sessionUpdate can no longer abort reconciliation before finishPrompt/rejectPendingPrompt. Ledger recording is still awaited and guarded, keeping the recovered chunk durable for loadSession replay.

Proof: new regression tests live in src/acp/translator.disconnects.test.ts (moved out of translator.stop-reason.test.ts, which hit the 1000 counted-line max-lines limit). Red: with the production changes stashed, both new tests fail — the delivery-failure test surfaces the unhandled client gone rejection from the old awaited delivery, and the suffix test sees no recovered chunk. Green: 27/27 across both test shards post-fix. oxlint/oxfmt clean; tsgo core + src test shards clean; git diff --check clean.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Round 3 pushed (cb3c82c427a) addressing the P1 finding "Claim the prompt before awaiting recovered delivery":

  • Terminal recovery now runs inside the prompt owner (settleRecoveredPrompt in translator.prompt-stream.ts): the prompt is claimed via claimPendingPrompt before the recovered delivery is awaited, then settled through the claimed path, so a late chat final can no longer re-emit the recovered suffix and a late chat error can no longer settle the run as end_turn ahead of the reconcile branch.
  • Two interleaving regressions added (hold the recovered chunk at the ledger-recording await — the actual awaitable window under waitForDelivery: false — then dispatch the racing event): duplicate-suffix race and error-settles-as-end_turn race. Both fail against the previous head and pass on this one.
  • Full src/acp/ suite: 60 files / 517 tests passed; oxlint/oxfmt clean; tsgo core + all 6 src test stripes clean.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Round 4 pushed (c5c23d25174) addressing the P1 finding "Normalize the recovered prefix before computing its suffix": the prefix check now uses the trimStart'd streamed text (streams are trimEnd-only; terminal replies are fully trimmed), so a streamed " final" correctly recovers " answer" from terminal "final answer" instead of dropping it. New regression test fails on the previous head and passes here; full src/acp/ suite 518/518, oxlint/tsgo clean.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Real ACP/Gateway reconnect proof added to the PR body (same reviewed head c5c23d25174, no code change). Real gateway from this head's dist + real ACP bridge + real ACP protocol client; the bridge↔gateway WebSocket is cut mid-run (TCP fault-injection proxy) while the model response is held, so the run completes gateway-side during the disconnect with zero chunks delivered to the client. After the bridge's real ~1s reconnect, reconcile recovered the full terminal reply exactly once and the prompt resolved end_turn. Transcript in the body. Scope note: this covers the bridge↔gateway disconnect path (where pending prompts live); a client↔bridge stdio break terminates the bridge by design.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 21, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Addressed the P1 finding ("Recover terminal replies returned with timeout status") on head b4b4374e062.

Change: reconnect reconciliation now routes a sticky timeout result that carries visible terminal reply evidence through the prompt-owner settlement path, matching the Gateway contract that reply evidence merges independently of sticky timeout/cancellation precedence (src/gateway/agent-turn/agent-wait-dedupe.test.ts).

  • src/acp/translator.disconnects.ts — the reconcile gate now admits timeout results with a visible terminalReply; timeout results without reply evidence keep the existing deadline behavior.
  • src/acp/translator.prompt-stream.ts — settleRecoveredPrompt settles timeout-with-terminal-evidence through the same recovered-suffix emission + end_turn path as ok.

Regression: recovers the terminal reply when the sticky timeout result carries reply evidence in src/acp/translator.disconnects.test.ts — agent.wait returns status: "timeout" + visible terminalReply; the recovered reply is emitted to the client, recorded in the event ledger, and the prompt resolves end_turn.

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: src/acp/translator.disconnects.test.ts 6/6 · src/acp/translator.stop-reason.test.ts 23/23 · all 34 test files under src/acp/ green (4 shards) · oxlint / oxfmt clean.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 22, 2026
@wangmiao0668000666
wangmiao0668000666 force-pushed the fix/acp-reconcile-reply-recovery branch from b4b4374 to 0dc2a2e Compare August 23, 2026 02:37
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Addressed the P1 finding ("Recover visible terminal replies on error results") on head 0dc2a2ec505 (rebased onto current origin/main).

Change: settleRecoveredPrompt now recovers the visible terminal reply (or missing suffix) for every terminal status before applying that status's settlement — one shared recovery path instead of per-status branches, per the merge-risk note. error results carrying a visible reply now replay it to the client and record it in the ledger before the interruption notice and rejection. Production delta: translator.prompt-stream.ts +23/−26 (net −3).

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 → translator.disconnects.test.ts 8/8, full src/acp/ 70 files / 591 tests green; oxlint/oxfmt/tsgo clean.

Real behavior proof on this exact head added to the PR body — three real-process ACP/Gateway reconnect scenarios (TCP proxy cut/resume, real @agentclientprotocol/sdk client, only the LLM endpoint stubbed):

  • ok + terminalReply during disconnect → reply recovered exactly once after reconnect, end_turn.
  • error during disconnect (hook-blocked run) → visible text surfaced + interruption + rejection.
  • agent-level timeout during disconnect → interruption + rejection instead of a silent end_turn.

Also noted in the body: the sticky timeout+terminalReply shape is a wait-layer/queue-phase gateway merge (contract-tested in agent-wait-dedupe.test.ts); the reconcile reader (timeoutMs: 0) never writes that entry in a minimal ACP+gateway pair, and bridge-side handling of it is covered by the round-4 regression plus this round's status-independent recovery.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 23, 2026
@obviyus
obviyus force-pushed the fix/acp-reconcile-reply-recovery branch from 0dc2a2e to d0c6973 Compare August 28, 2026 16:37
@obviyus

obviyus commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

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.

  • Bug: A reply that finished while ACP was disconnected vanished, and a failed run looked successful after reconnect.
  • Fix: The prompt owner now claims the run, records and emits the missing reply once, then resolves or rejects from the real Gateway terminal status.

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

Before After
Gateway finishes final answer while ACP is offline; reconnect returns end_turn with no text. Reconnect delivers final answer once, then returns end_turn.
Gateway reports a run error while ACP is offline; reconnect returns end_turn. Reconnect shows the interruption and rejects the prompt.

@obviyus
obviyus merged commit ca7e9e1 into openclaw:main Aug 28, 2026
195 of 196 checks passed
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

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. 🙏

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
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]>
@wangmiao0668000666
wangmiao0668000666 deleted the fix/acp-reconcile-reply-recovery branch October 28, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP reconnect reconcile drops a completed run's reply and swallows run errors as end_turn

2 participants