Repository navigation
fix(claude-cli): store every reply in chat history, not just the final one - #196092
Marvinthebored wants to merge 5 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesPersists individual Claude CLI assistant replies so earlier text survives native-session replacement, interruption, and failure. Example: Claude writes a story, starts
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a persistence bug still present on current main, and its latest commit resolves the prior test finding; no new blocking defect was identified, while current-head CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe CLI runner converts Claude stream records into assistant messages, persists them through the session transcript owner, and supplies live and saved history to the Control UI. flowchart LR
A[Claude CLI] --> B[Stream parser]
B --> C[Serialized transcript writes]
C --> D[Session storage]
B --> E[Live events]
D --> F[Gateway history]
E --> G[Control UI]
F --> G
Technical reviewBest possible solution: Persist each native assistant snapshot through the canonical transcript writer, preserve identity-based deduplication, and settle its disposition without replacing its content. Do we have a high-confidence way to reproduce the issue? Current-main source and the detailed report in #195856 establish the final-only persistence path; this read-only review did not execute a reproduction. Is this the best way to solve the issue? The change repairs durability at the existing transcript owner, retains native identity matching, and updates affected stream consumers without introducing another storage system or configuration option. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b645c81c96e0. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +823, Tests +1236, Other +3. Total +2062 across 42 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (16 earlier review cycles; latest 8 shown)
Reviewed November 20, 2026, 10:48 PM ET / November 21, 2026, 03:48 UTC (Revision 17). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Added a live upgrade run from latest stable v2026.11.5 to the reviewed head |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Merge main into the original contributor branch. Retire only the live occurrences owned by a committed snapshot, preserve native tools in display history, and settle interrupted output under the transcript writer rather than the canceled model execution. Co-authored-by: jalehman <[email protected]>
Use the same native key for reply comparison, provenance, and settlement. Keep checkpoint-only boundaries when a session is not yet known. Pass a receiver-independent snapshot callback and join Gateway test handlers at teardown. Co-authored-by: jalehman <[email protected]>
Record only the failing fixture phase, category, and HTTP status. Keep the real nonzero child exit and let the parent report the diagnostic rather than dumping the scheduled job. Co-authored-by: jalehman <[email protected]>
Closes #195856
Related: #164293, #166511
What Problem This Solves
Fixes: with the
claude-clibackend, replies sent before the final message vanish after a CLI session rotation, or after a run is killed or fails.User Impact
User impact: completed user-addressed replies remain in the conversation after a session reset. Text from an interrupted run remains visible, marked "Interrupted". Yielded progress remains progress; scheduled execution prose retains its audit-only policy.
Why This Change Was Made
Previously, only the final reply was durable; earlier replies depended on the currently bound Claude log. This change buffers the latest revision per native UUID and persists it when the next assistant record arrives or the process ends. Writes retain normal preparation hooks and ownership checks. Final settlement deduplicates by native identity and awaits queued writes, including on failure.
The change works with commentary streaming enabled or disabled. #164293 covers commentary-enabled persistence; #166511 covers a watchdog interruption slice.
Settlement uses a closed assistant-metadata operation: content, identity, timestamps, topology and replay inputs cannot change. It preserves the transcript generation and returns the current anchor without relaxing generic rewrite invalidation or changing account admission.
Evidence
Scheduled Claude fixture diagnostics — 3d6297baf2c7
The failed hosted case had reached its intentional clock advance, but retained only the child’s exit code. This test-only change keeps the nonzero exit and failing cron status, and reports the synthetic child's failing operation and a bounded reason without dumping a scheduled job, input, or credentials. It does not relax the exactly-one-edit or cancellation assertions.
tools/listand separately identified malformed tool arguments. These controlled failures do not identify the historical exception.November 25 CI correction — b3ff347256fb
The preceding CI run found two type-aware lint errors and two new session-ID comparisons. The correction reuses the native snapshot key for comparison and settlement, makes the stream callback independent of its receiver, and awaits outstanding event handlers at test teardown. No test expectations, lint rules or baseline allowances changed. Pinned Oxlint reproduced both diagnostics before the fix and reported none afterward; the identity ratchet, formatting and whitespace checks passed. Independent source review found no actionable issues.
Two other Gateway failures are inherited: the Goal role-loss assertion at line 522 reproduced with the same expected/received error on the clean CI base
bb0fc6578574, using a test-only home. The in-process continuation assertion at line 325 has the same failure on scheduled main CI. Neither assertion was changed. Hosted CI on the correction passed the repaired lint and identity checks, but the overall gate failed. Three test jobs failed:16461 > 16461).The synthetic fixture is not the requested real Claude CLI Stop → native-session rotation → reload test in Crabbox. That live flow remains unverified; no merge or bypass was requested from CI.
November 25 conflict repair — 539606146735
Merged main at
e5658a03516dinto the original contributor branch. The repair keeps participant limits and the transcript writer lease, and reconciles saved replies with current chat progress handling. Focused regressions cover mixed text/tool rows, synthetic Stop notices, text after a held reply, and distinct native replies with identical text.Source review, syntax/format checks and
git diff --checkcompleted. Hosted CI is separate. The real Claude CLI Stop → native-session rotation → reload flow has not been verified on this commit. Earlier live results below apply only to their named commits.Earlier focused proof
Upgrade from latest stable v2026.11.5 to head
7b3e9d23b50Both builds were made from clean checkouts (buildstamps
e13cf15ece9= v2026.11.5, and7b3e9d23b50). One throwaway Gateway state directory was used, with theclaude-clibackend, driven through the real Control UI.DONE-A), then a ~120-word story streamed as visible text with Stop pressed while itssleep 60tool was running (tool start observed at 6.70 s, Stop clicked at 6.84 s). The story stayed visible, marked "Interrupted", live and after reload.user_versionwent from 38 to 42.quick_checkreturnedokbefore and after. A pre-migration backup was written, and its integrity check passes.DONE-Aonce and the interrupted story once.REPLACEMENT-OK-196092settled as a new message. The local session ID is unchanged, and the Claude CLI binding moved to a new native session. The imported reply matches the new binding. After reload,DONE-A, both interrupted stories and the new reply each appear exactly once, and two events are appended after the unchanged 11.cli session reset … reason=mcp. The resume-hash canonicalization inbundle-mcp.ts, which this PR does not change, now normalizes the openclaw server'salwaysLoad. As a result, bindings stored while tools were deferred do not match once after upgrading.v2026.11.5, story interrupted by Stop, after reload · after upgrading, same session before a new turn · after the replacement turn, after reload:
November 18 conflict-repair update —
51bc1056a612Updated against main
b609d22c129f2944c1abaec1d2895eb659493a36, preserving the newer transcript-lease and stopped-first-session recovery behavior.final: false) delivery; matching mirrors are hidden without promoting progress into completed-answer evidence.git diff --check, and exact-base max-lines/test-lines ratchets passed. The test allocation is 860 lines beyond the ordinary 400-line allowance, covering native identity/settlement and the held-reply/commentary/terminal-revision/delivered-failure regressions. Whole-change net delta against this base: +831 production lines and +1,260 test lines. Stream framing and budget accounting now live together in the existing stream-limits owner, with unchanged limits, keeping the parser within its file-size cap.7b3e9d23b50. The other live Claude/Control UI evidence below is retained from the stated earlier revisions. Current-head hosted CI must be read separately; no prior-head result is represented as a current-head pass.Earlier implementation evidence
DONE: STEER-A, STEER-B, STEER-Clive and after reload. Narration stays between the steers.stopReason: "stop"and nonzero usage.display: falseanddisplay: true.Final live settlement and after reload:
Prior live-proof head
9bc5ccf5489: Stop retention, native replacement, single narrationThrowaway proof Gateway built at the exact head (buildstamp
9bc5ccf5489, clean inputs), driven through the real Control UI with theclaude-clibackend:sleep 60tool was pending. The story remains visible exactly once, marked "Interrupted", both live and after a full page reload; no tool card or error banner is left behind.REPLACEMENT-OK-196092) settles as a new assistant message; the interrupted story is retained exactly once, live and after reload.Narration Nline exactly once while streaming; the final accumulated assistant message contains each of the six lines exactly once (192 chars), with no duplicated narration live or after reload.control-ui-performanceand the max-lines ratchet are green at this head.checks-node-changed-compact-large-11-1— 7 tests inrun.prepared-harness-source-delivery.integration.test.tsfailing with therun-loop.ts:501 .providerOutcomesTypeError introduced by main fix(agents): explain when a listed model rejects a chat request #200073. The identical 7 failures reproduce on the pure merge base30e9d3ee295(local attribution run); this PR touches noembedded-agent-runnerfiles. Inherited from main, not caused by this change.Stop retention (live, then after reload):
Native replacement (live, then after reload):
AI-assisted: implementation and validation with Claude and GPT agents.
Original PR author: @Marvinthebored. The work-session link below records the November 18 PR update.
Work sessions
Linked for team reference; these sessions aren’t public.
Discussion, implementation and verification
Original discussion with @jalehman — November 25 repair and live-proof request
Implementation and verification — November 25 conflict repair and source checks
CI correction and static verification
Fixture diagnostic implementation and isolated verification
Round 5 (head
267a360d9d7): source-reply delivery no longer hides distinct snapshotsAddresses the 16 Nov ClawSweeper P2 (
cli-assistant-settlement.ts:146). When a message tool delivers the source reply, settlement now marksdisplay:falseonly on saved snapshots whose text matches a delivered source-reply body (the dispatch-owned mirror). Distinct earlier snapshots such asFindings: BLUE-HERON-42followed by a tool-deliveredDonekeep their prepared visibility.keeps distinct snapshots visible when the message tool delivers a different reply, plus the settlement matrix now asserts per-row visibility (mirroredAnswerhidden, distinctProgressvisible). Both fail on9bc5ccf5489(2 failed) and pass after the fix.cli-run-transcript.test.ts,cli-runner.history-ownership.test.ts,cli-session-history.segments.test.tspass;tsgo:core, oxlint/oxfmt, max-lines and test-lines ratchets clean.9bc5ccf5489) still covers them.