Repository navigation
fix: prevent duplicate Claude answers in session history - #167069
jaxonparrott wants to merge 7 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR records which native Claude text belongs to an accepted reply so history can remove duplicate text while preserving distinct turns, tools, and thoughts. Example: A Claude turn emits “Checking the result.”, calls lookup, and finishes with “Verified answer.”
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: it addresses a concrete Claude history correlation bug that remains on current main, and the earlier replacement-message defect is fixed with no new blocking code findings. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe CLI parser selects answer text, the transcript writer persists its source receipts, and the Gateway’s worker-owned history index combines canonical messages with native Claude records for clients. flowchart LR
A[Claude CLI records] --> B[CLI streaming parser]
B --> C[Canonical transcript writer]
C --> E[Worker history index]
A --> D[Native history importer]
D --> E
E --> F[Gateway history response]
F --> G[Chat clients]
Technical reviewBest possible solution: Keep exact accepted-text correlation in the existing parser, transcript writer, and worker history owner while preserving canonical content and distinct native turns. Do we have a high-confidence way to reproduce the issue? Current-main source supports the multi-text trigger: an identityless canonical aggregate cannot text-match its unequal native fragments, consistent with the detailed release reports; this review ran no target code. Is this the best way to solve the issue? Exact source identity plus full-text coverage is a sound repair because it preserves answer-selection policy and avoids collapsing unrelated equal answers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against db550ef2d43e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +401, Tests +961. Total +1362 across 17 files. Added test files: 1. 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. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (8 earlier review cycles)
Reviewed October 10, 2026, 6:23 AM ET / 10:23 UTC (Revision 9). |
abe43db to
fe52593
Compare
fe52593 to
8371489
Compare
|
Additional downstream evidence: the narrow producer-receipt preservation port is deployed in native source After an actual production restart from the previous native build, three previously completed real Claude child sessions were reopened through native history. Persisted messages and producer receipts exactly matched their pre-upgrade records: one user, retained real Read call/result, one canonical final answer, zero duplicates per session. This proves saved-history continuity for those observed records; it does not claim live coverage of all hook replacements, multi-text or thinking shapes, or the exact upstream head. |
|
This pull request has been automatically marked as stale after 7 days without qualifying human activity. |
|
Closing due to inactivity. |
October 10 contributor update
The replacement-message defect is fixed at the CLI producer. After an accepted hook or preparer returns, producer receipts are restored only when the final authored text still equals the accepted aggregate. Rewritten content loses stale receipt correspondence; blocked writes remain blocked. Regression controls cover a fresh hook object without metadata, a preparer dropping metadata, rewritten text, and blocked persistence.
Integrated current upstream main
ff1303e4e8to resolve the parser conflict. The combined upstream assistant/commentary flush retains buffered receipt selection for accepted assistant text and discards commentary correspondence.Current contributor head:
14e879642b19e3f04bc1ff5c337a979f5bb4a9bd. Exact-head GitHub CI has a failed UI E2E job; no full CI pass is claimed for this head. Current Railway source gates (Linux, Node 24.21.0, pinned pnpm 12.9.0): frozen-lock install passed (32.9s); parser, native history, and history paging suites passed 88 assertions in the four-file qualification run (209.74s overall). Final persistence-only replay passed 9/9 (64.96s), covering both original coordination/run-ID assertions and the separate replacement/rewrite/block/preparer controls. All three touched files passed final type-aware lint with zero warnings/errors (24.4s); the final test-only adjustment renames a shadowed local variable without changing the green test behavior. Local and Railway source digests match;git diff --checkpassed. Fresh independent review found no blocking code findings.The subsequent
check-test-types-core-2failure was confined to the new hook fixture. The fixture now narrows assistant messages, returns a fresh spread preserving mandatory provider/runtime fields, explicitly removes__openclaw, and assigns rewritten content through the typed assistant object. This preserves the receipt-loss discriminator without incomplete-message union typing. On a new disposable Railway sandbox: frozen-lock install passed (30.3s), the exact previously failingtest/tsconfig/tsconfig.core.test.agents-other.jsonleaf passed, one-file type-aware lint passed with zero warnings/errors (31.0s), and the existing persistence suite passed 9/9 through the native agents-support config (190.27s including cold worker compilation). Source digests match. Initial default-workspace scanning encountered upload-generated AppleDouble sidecars; those were removed from the disposable source. Unit/core launcher attempts collected no tests and are not qualification. No production code changed in this final correction.Exact-head UI E2E shard 1/2 failed two
session-dashboard.e2e.test.tspin cases (81 tests passed): Playwright timed out after 30s because SVG/span children ofchat-gutter-stack--detailsintercepted clicks on “Pin to dashboard.” The cases install mock Gateway history directly and do not execute the CLI producer/persistence fixture. UI source, workflow/test configuration, and the test launcher are unchanged from the merged upstream baseff1303e4e8. This is an inherited UI hit-testing failure; no claim about intermittency or baseline test execution is made. The focused type leaf, typed lint, and 9/9 persistence receipts above remain valid. No UI fix or rerun was added to this receipt PR.Read-only inspection of three existing owned production Claude handoff turns at
fa05b483af7a72949c3ea738dff33a721af18453now establishes a real tool→producer receipt→Gateway history path: each native final UUID and authored-text SHA256 matches its canonical receipt, history returns the answer once, and the preceding Read call/result remains. These are ordinary single-text finals following a tool call; native records contain no thinking/signature blocks. The receipt consumer file is byte-identical to this upstream head, but fa05 has earlier stream/producer source and lacks the replacement-object repair. This closes the absence of any authentic ordinary receipt/history observation, not exact-head repair, multi-text/thought retention, or upgrade proof. Owned source/history evidence is retained privately; no transcripts or credentials are published.The initial four-file run also exposed an existing separate ownership defect: fresh-object replacements drop preattached
__openclaw.runId, soreadSessionTranscriptRunId(update.message)becomes undefined. Original spread-object run-ID assertions remain intact and pass; the new replacement cases scope their assertions to receipt correspondence. This PR does not repair generic run-ID preservation. A broad core compiler run exhausted the sandbox's working memory and was terminated; no full core typecheck pass is claimed. The contention-affected persistence replay was interrupted and then rerun serially to the green result above. Earlier evidence below remains attributed to its original head. Current-head contributor qualification remains synthetic. The fa05 ordinary real-tool observation above is version-scoped; an authentic after-fix replacement/multi-block turn, latest-stable transcript upgrade and reopen, and upstream history-owner acceptance remain outstanding. No production activation or merge is claimed.What Problem This Solves
Fixes duplicate assistant answers when an imported Claude CLI transcript and OpenClaw's canonical reply represent the same provider turn, while preserving distinct turns and non-text records.
User Impact
Users receive one copy of the accepted answer. Tools, thoughts, signatures and native provenance remain visible. Historical rows without valid receipts retain their compatibility behavior; canonical history and durable database schemas are unchanged.
Why This Change Was Made
The parser records fully selected text under provider, session and native record UUID with an exact body digest. The derived history index consumes only text proven by that receipt. Receipt-bearing replies cannot use the legacy text fallback to consume a distinct UUID with an identical answer. The trusted importer carries the original digest separately from the redacted display payload; external metadata cannot supply this fact. Each selected source occurrence retains its exact identity, including multiple content records sharing a message ID.
Refreshed onto official main
3223e13a514c6134e10ee7f585627434d245fd20, consuming the landed native fixes for prior inherited CI failures. The complete feature patch is byte-for-byte equal to the prior revision; range-diff keeps every commit equal, and upstream changed none of this PR’s touched files. The stream conflict preserves upstream #165031's interrupted raw-tool-protocol rejection, text selection, code-region exclusion, fallback, and checkpoint semantics. Partial receipts attach only in the accepted-output branch. Three parser controls cover accepted prose, rejected unfinished raw protocol with no receipt, and an accepted fenced XML example. No patch was superseded by this base.Evidence
Reviewed source head:
837148900f34eb65a2eafe7f5fd9aa1ee0861660. Exact-head native CI completed successfully: 46 successful jobs, 27 skipped, no failures or unfinished jobs. Prior-head failures and passes below remain historical. No maintainer acceptance or merge is claimed.Prior Railway proof used Linux, Node 24.20.0 / pnpm 12.5.1 and one frozen-lock install. Current upstream uses pnpm 12.7.0, TypeScript 7.1.0-dev.20260922.1, oxlint 1.85.0, tsgolint 7.0.2003 and oxfmt 0.71.0. The successful exact-head native CI qualified its selected checks against this changed dependency graph; no duplicate local suites or installs were run. Existing receipts remain attributed to their exact prior source heads:
dc83c3e3exited 0: seven files across four shards, 140 passed / no skips, wall 319.02 seconds. The 16-case receipt shard, including the three new partial-output controls, completed in 6.11 seconds. The affected three-file Gateway shard completed 49 cases in 199.18 seconds.50ddGateway baseline passed 44 cases across four files, wall 406.91 seconds, including 199.948 seconds of cold worker-artifact preparation. These are differently grouped measurements, not a performance comparison.fe52593apassed all 16 cases with no skips, wall 12.18 seconds (Vitest 3.39 seconds). It removes a redundant dialect predicate: receipt construction already requires the Claude dialect. Native callers preserve the per-turn provider/dialect; custom-event exclusion and interrupted raw-protocol rejection remain intact.fe52593apassed native changed formatting and type-aware lint for all 17 changed files: zero warnings/errors, wall 136.42 seconds. The existing changed-file planner selected these commands withlintOnly: true, exact base50dd07c2and headfe52593a; no hand-filtered lint set.dc83c3e3failed the native 700-line limit by one line. The final delta removes the redundant condition without a suppression or limit change.check:changedand remaining type graphs were not repeated before this contributor update. The successful new-head GitHub CI owns its selected proof; no complete local check:changed PASS or maintainer acceptance is claimed.fe525failed the inherited assertion allowance mismatch and Windows listener argument error, plus the aggregate gate. Both are now fixed at their native owners: Peter’s allowance correction and signal argument correction. No duplicate fixes were added here. The refreshed head’s successful native CI is linked above; no prior failure was relabeled as a pass.git diff --checkpassed and the reviewed source tree remained clean.Prior-head evidence remains historical:
abe43dbepassed 95 assertions, core types, selected agent/Gateway graphs, formatting and typed lint. Earlier real entry-point controls reproduced the identical-body rival, redaction-boundary duplicate, and per-block occurrence loss; earlier drafts also failed exact-repeat and buffered-final selection controls before correction. Prior scoped-clean reviews did not establish absence of those later findings. Beta-runtime and prior-head receipts do not substitute for current-head CI proof. Native staging recorded a transport deadline and an obsolete pnpm launcher failure before the successful durable fetch/install; neither is test-pass evidence.A launcher metadata error admitted duplicate receipt-only jobs; both completed and were settled before the final attributed receipt run. They are not counted as additional coverage.
All fixtures are synthetic; no private transcripts or production data. These are scoped source gates; no full package build, production activation, or blanket repository CI pass is claimed.