fix: keep the final answer after a progress message in claude-cli chats (#200470) Root cause: src/agents/cli-runner/terminal-reply.ts:66 (on main) clears a non-final source-reply mirror only for result-required turns. In a required message-tool-only turn (a direct WebChat chat), a `final: false` progress send therefore counts as the delivered reply and replaces the CLI's later visible final answer. Related: #187827 reports the same symptom on the release line. This PR fixes current main and is not that backport. ## What Problem This Solves Take a WebChat (Control UI) chat with a `claude-cli` agent that must reply through the `message` tool (`messages.visibleReplies: "message_tool"`). The agent can send a progress update with `final: false`, keep working, and end with a plain-text answer. That answer was dropped. The progress send counted as the turn's reply, so the answer was never saved to the conversation and never went through the normal undelivered-reply recovery. The user was left with the progress line as the answer; the final text showed only through the Claude Code session import. ## User Impact A required turn that sends progress and then answers in plain text now behaves like a required turn that answers in plain text with no progress. The answer is saved to the conversation, and the existing undelivered-reply recovery runs once so the agent can deliver it. Optional turns are unchanged: progress still completes them and their final text stays private. Turns that end in `NO_REPLY`, or that already delivered their answer with a `final: true` send, are also unchanged. ## Why This Change Was Made `prepareCliRunTerminalReply` is the one place that decides whether message-tool sends replace the CLI's terminal text. It now classifies the raw terminal reply first. For a `required` turn that ended with a visible answer, it drops a mirror made only of progress sends (`final: false`). This matches the stranded-reply recovery owner (`isStrandedPrivateMessageToolFinal`), which also acts only for required turns. Optional `message_tool_only` turns keep the behavior that #177417 relies on: progress completes the turn, the private terminal text stays out of the transcript, and the existing test for that case is unchanged. No config, schema or delivery-policy changes. Thanks @chaeyn for the fix and the original live proof, and @jorge-monalee for the detailed report in #187827. ## Evidence - Setup: isolated Gateway from built `dist/`, real Claude Code 2.1.322 as the `claude-cli` runtime against a local Anthropic fixture (no real provider), `messages.visibleReplies: "message_tool"`, one WebChat-route `chat.send` (a required turn). Base `5e677bad858c` (main). Candidate: the `079270d1b7d9` tree. - Progress then plain final, base: the canonical transcript has only `PROGRESS-...`. No recovery runs, and the final exists only in the Claude session import. - Progress then plain final, candidate: the canonical transcript has `PROGRESS-...` and `FINAL-...`, then the recovery run delivers `FINAL-...` once through `message`. - Plain final with no progress, on base and candidate: `FINAL-...` is saved, then the recovery delivers it once. This matches the candidate progress turn. - Control, where one `final: true` send is the whole reply: one `CONTROL-...` row, no recovery, no duplicate. - Regression: the `cli-runner.reliability` case "keeps the final answer after WebChat progress in message_tool_only" fails on main (`expected [ 'Build started.' ] to deeply equal [ Array(2) ]`) and passes with the fix. - Unchanged consumer test: `agent-command.live-model-switch` (#177417's optional progress-then-private-text case) passes with the test file byte-identical to main. Both files: 157 passed. - Optional case on the built Gateway (#177417 shape): an exec-completion wake sends `final: false` progress and ends with private text. Base and candidate are identical: the progress row is stored, the private text is not, and no recovery runs. - Diff vs merge base: production +12/-4 in `terminal-reply.ts`, test +44 (one case). Live proof capture: https://github.com/openclaw/openclaw/pull/200470#issuecomment-6971159033 Merge danger: two-way door. A revert fully undoes it; no state, config or contract changes. Blast radius: required CLI-backend turns that send `final: false` progress through the message tool and then end with visible text. If the change is wrong, such turns could show the final answer twice or run the undelivered-reply recovery once more than needed. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Ayaan Zaidi <hi@obviy.us>
fix: keep the final answer after a progress message in claude-cli cha…
Find Your Interest
- Guerrero
- El futuro de Banxico y un relevo en puerta
- CloudNativePG becomes a CNCF Incubating Project
- SpecGuard: When AI Coding Agents Write Tests That Approve Bugs
- Introducing iMore Labs
- El PSOE reclama 320.000 euros a Hazte Oír por comparar a Sánchez con Hitler
- Contradicción constitucional detona guerra anticipada
- Consenso en suspenso
- Vuelve ‘El Jaguar’, pero naranja: Armando Ríos Piter va por la candidatura de Guerrero con MC
- Andre Blake conoce la fórmula para dejar a México sin gol





