fix(session-memory): deduplicate consecutive assistant messages with identical text#92966
fix(session-memory): deduplicate consecutive assistant messages with identical text#92966hnlqt666 wants to merge 2 commits into
Conversation
…identical text When thinking/reasoning is enabled, the session JSONL stores both the original assistant message (with thinking blocks) and a stripped copy (without thinking blocks), causing session-memory hook to produce duplicate entries. Skip consecutive assistant messages with identical text content to avoid doubling every assistant reply in memory files. Fixes openclaw#92563
|
Thanks for the context here. I did a careful shell check against current Current main already contains the narrower semantic session-memory fix from a merged canonical PR, so this older broad text-dedup branch should close rather than remain a landing candidate. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. So I’m closing this as already implemented rather than keeping a duplicate issue open. Review detailsBest possible solution: Keep the merged semantic current-main implementation from #94401 and close this older broad-dedupe branch. Do we have a high-confidence way to reproduce the issue? Yes. The original bug is source-reproducible from the transcript reader path: duplicated raw plus delivery-mirror assistant rows become duplicated session-memory lines without the semantic filter. Is this the best way to solve the issue? No. This PR is a plausible workaround, but current main’s delivery-mirror-aware filter is the safer and narrower solution because it preserves legitimate same-text assistant rows. Security review: Security review cleared: The diff only changes local session-memory transcript filtering and tests; it adds no dependency, workflow, secret, auth, network, or command-execution surface. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 5a73361ed2b3; fix evidence: commit 1052652a7168, main fix timestamp 2026-06-29T15:19:25Z. |
|
ClawSweeper applied the proposed close for this PR.
|
When thinking/reasoning is enabled, the session JSONL stores both the original assistant message (with thinking blocks) and a stripped copy (without thinking blocks), causing session-memory hook to produce duplicate entries.
Skip consecutive assistant messages with identical text content to avoid doubling every assistant reply in memory files.
Fixes #92563
Summary
Linked context
Closes #92563
Real behavior proof (required for external PRs)
pnpm exec vitest run --config test/vitest/vitest.hooks.config.ts src/hooks/bundled/session-memory/handler.test.tsTests and validation
Which commands did you run?
pnpm exec vitest run --config test/vitest/vitest.hooks.config.ts src/hooks/bundled/session-memory/handler.test.tsWhat regression coverage was added or updated?
Added 2 test cases to
handler.test.ts:What failed before this fix, if known?
Session-memory output contained duplicate entries for every assistant reply when thinking/reasoning was enabled.
Risk checklist
Did user-visible behavior change? (
Yes)Did config, environment, or migration behavior change? (
No)Did security, auth, secrets, network, or tool execution behavior change? (
No)What is the highest-risk area?
The dedup logic could accidentally drop a legitimate consecutive identical assistant reply.
How is that risk mitigated?
Only skips when the immediately preceding assistant message has identical text. User messages break the chain. Two unit tests validate both paths.
Current review state
What is the next action?
Ready for maintainer review.