fix(agents): dedupe transcript rewrite suffix replay#89387
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 7:56 PM ET / 23:56 UTC. Summary PR surface: Source +81, Tests +173. Total +254 across 2 files. Reproducibility: yes. at source level: current main replays every transcript rewrite suffix entry, and the linked issue provides persisted JSONL/log evidence. I did not run a live forced-overflow reproduction in this read-only review. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Rebase onto current main, preserve current transcript rewrite branch/leaf behavior, keep the narrow replay dedupe, and merge only after redacted persisted-session/live overflow proof or an explicit maintainer proof override. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main replays every transcript rewrite suffix entry, and the linked issue provides persisted JSONL/log evidence. I did not run a live forced-overflow reproduction in this read-only review. Is this the best way to solve the issue? Yes as a scoped repair shape: the shared transcript rewrite seam is the narrow maintainable layer because overflow tool-result truncation and context-engine maintenance both call it. The PR is not merge-ready until conflict resolution and real-behavior proof or maintainer override are handled. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 18b2ff683fd3. Label changesLabel justifications:
Evidence reviewedPR surface: Source +81, Tests +173. Total +254 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (1 earlier review cycle)
|
Context-overflow recovery re-runs transcript suffix replay (rewriteTranscriptEntriesInSessionManager / rewriteTranscriptEntriesInState) without a replay-identity guard, so byte-identical role=user entries are re-appended on every recovery pass. The persisted session JSONL then accumulates duplicate messages, amplifying transcript growth and cascading into further overflows. Collapse only the proven overflow-clone pattern during replay: byte-identical role=user messages (whose timestamp distinguishes a recovery clone from a legitimate repeat) and byte-identical compactions (identity folds in the remapped firstKeptEntryId so distinct kept boundaries survive). Exact suffix history is preserved for assistant, tool-result, and custom entries, whose identical payloads can be legitimate history. Closes openclaw#66443
f0591e3 to
2e18181
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
Summary
Context-overflow recovery re-runs transcript suffix replay without a replay-identity guard, so byte-identical
role=userentries are re-appended on every recovery pass and the persisted session JSONL accumulates duplicate messages (issue #66443).role=usermessages and byte-identical compactions. Exact suffix history is preserved for assistant, tool-result, and custom entries.firstKeptEntryIdso two distinct compactions are not merged.Linked context
Closes #66443
Related #79150 — superseded prior attempt; this PR addresses its "include the kept boundary in compaction identity" review note.
Not maintainer-requested; selected from the
clawsweeper:queueable-fixbacklog.Real behavior proof (required for external PRs)
role=userentries in the persisted session JSONL (issue Overflow recovery duplicates role=user messages in session JSONL, amplifying transcript growth #66443 captured one unique message stored as three byte-identical copies).rewriteTranscriptEntriesInSessionManagerandrewriteTranscriptEntriesInStateagainst a real in-memorySessionManagerand persisted transcript-file-state — these functions are run for real, not mocked.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/transcript-rewrite.test.tsmainand passes after the fix, and added tests prove legitimate repeats survive:role=userclone is collapsed to one entry, while (a) two user messages with distinct timestamps, (b) byte-identical repeated assistant/tool-result entries, and (c) two distinct compactions are all preserved.crabbox check:changedgate). A maintainer with a live setup can confirm end-to-end behavior, or applyproof: overridefor this logic-only dedup fix; I am happy to add a live capture if someone can reproduce an overflow.expected 2 to be 1) is the before-state captured from unfixedmain.Tests and validation
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/transcript-rewrite.test.ts-> 10 passed (4 new).tool-result-truncation,context-engine-maintenance,compact.hooks,cli-runner.context-engine-> 126 passed.tsgo -p tsconfig.core.jsonand core test types: no errors in the changed files (two unrelated pre-existing errors insrc/config/io.tsandsrc/secrets/config-io.tsare present onmain).transcript-rewrite.test.ts: clone collapse (fails first withexpected 2 to be 1, passes after); distinct compactions preserved; legitimate repeated user messages (distinct timestamps) preserved; byte-identical repeated assistant/tool-result entries preserved.Risk checklist
merge-risk: session-stateconcern).role=usermessages and compactions only; the full-payload hash (including timestamp) distinguishes a recovery clone from a legitimate repeat; compaction identity includes the remappedfirstKeptEntryId; assistant/tool-result/custom entries are never deduped. Covered by the four regression tests above.Current review state
proof: override.