Skip to content

fix(session-memory): skip delivery-mirror entries and dedup consecutive identical assistant messages (#92563)#93267

Closed
fsdwen wants to merge 3 commits into
openclaw:mainfrom
fsdwen:fix/92563-session-memory-dedup
Closed

fix(session-memory): skip delivery-mirror entries and dedup consecutive identical assistant messages (#92563)#93267
fsdwen wants to merge 3 commits into
openclaw:mainfrom
fsdwen:fix/92563-session-memory-dedup

Conversation

@fsdwen

@fsdwen fsdwen commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

getRecentSessionContent 未对 consecutive assistant 消息做去重,导致
thinking 模型的 raw(thinking+text) 和 cleaned(text-only) 消息在 session
memory 中产生重复行。

修复: 连续相同文本的 assistant 消息仅保留第一条,遇到 user 消息重置状态。

Fixes #92563

Verification

vitest: 28/28 通过

 ✓ preserves standalone delivery-mirror replies with different text (#92563)
 ✓ dedupes delivery-mirror that duplicates preceding assistant text (#92563)
 ✓ dedupes consecutive identical assistant messages (#92563)
 ✓ keeps repeated assistant reply after an intervening visible user message (#92563)

修复前 vs 修复后对比

修复前(无去重)                          修复后(有去重)
user: 帮我看看今天天气                    user: 帮我看看今天天气
assistant: 请告诉我你所在的城市... ←raw    assistant: 请告诉我你所在的城市...  ← 一条
assistant: 请告诉我你所在的城市... ←重复   user: 上海
user: 上海                                assistant: 上海今天多云...
assistant: 上海今天多云...

"请告诉我你所在的城市" 出现: 2 次 ❌        "请告诉我你所在的城市" 出现: 1 次 ✅
assistant 行数: 3                          assistant 行数: 2

🤖 Generated with Claude Code

…ve identical assistant messages (openclaw#92563)

- Skip assistant messages with provider=openclaw and model=delivery-mirror
  in getRecentSessionContent, since they duplicate the visible text of the
  preceding assistant message and belong to delivery bookkeeping.
- Dedupe consecutive assistant messages with identical visible text as a
  safety net for any other path that produces redundant rows.

Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

This PR contains useful session-memory bugfix work, but it is no longer the best landing path because a newer clean, proof-positive PR owns the same linked bug with the narrower existing transcript-only assistant filter.

Root-cause cluster
Relationship: superseded
Canonical: #94401
Summary: The current PR, the linked issue, and the newer replacement PR address the same duplicate assistant lines in session-memory; the newer PR is the canonical open landing path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this branch and continue review on #94401 as the canonical helper-based session-memory fix for the linked bug.

So I’m closing this here and keeping the remaining discussion on #94401.

Review details

Best possible solution:

Close this branch and continue review on #94401 as the canonical helper-based session-memory fix for the linked bug.

Do we have a high-confidence way to reproduce the issue?

Yes at source level. Current main appends every extracted user/assistant text row, so a raw assistant entry plus a transcript-only delivery-mirror or gateway-injected copy can produce duplicate assistant lines in session-memory output.

Is this the best way to solve the issue?

No. The broad text-dedup approach is a plausible mitigation, but the existing transcript-only assistant helper is the narrower maintainable fix and is already used by the clean canonical PR.

Security review:

Security review cleared: The diff only changes session-memory transcript filtering and colocated tests; it does not touch dependencies, CI, scripts, secrets, permissions, or code-execution surfaces.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • vincentkoc: Recent GitHub history for the shared transcript-only assistant helper and session-memory handler fixes points to vincentkoc, including the delivery-mirror history-row helper work and session-memory filename/reset-path fixes. (role: recent area contributor; confidence: high; commits: c12d921291bb, f5eddc2b6d1f, 61383aff4b8d; files: src/shared/transcript-only-openclaw-assistant.ts, src/hooks/bundled/session-memory/handler.ts, src/hooks/bundled/session-memory/transcript.ts)
  • steipete: GitHub history for the transcript helper and handler shows hook-helper documentation, hook helper exports, lightweight runtime seams, and broad session/runtime refactors by steipete around this area. (role: historical feature and refactor contributor; confidence: medium; commits: 4c3b4f8ad8f8, 238867ca51f1, 8727338372b4; files: src/hooks/bundled/session-memory/transcript.ts, src/hooks/bundled/session-memory/handler.ts)
  • rbutera: Earlier session-memory reset-path work changed the same handler/test area and is relevant context for /new and /reset memory capture behavior. (role: earlier reset-path contributor; confidence: medium; commits: c94265545167; files: src/hooks/bundled/session-memory/handler.ts, src/hooks/bundled/session-memory/handler.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 23b8f5d03782.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 15, 2026
fsdwen and others added 2 commits June 15, 2026 19:24
…livery-mirror skip (openclaw#92563)

- Replace unconditional delivery-mirror skip with consecutive identical-text
  dedup that preserves standalone delivery-mirror replies while still handling
  the raw/cleaned thinking duplicate case.
- Standalone delivery-mirror rows that differ from the preceding assistant
  text are now preserved, matching the chat history contract.

Co-Authored-By: Claude <[email protected]>
…ross-turn replies (openclaw#92563)

- Reset lastAssistantText when a visible user message is included in the
  memory summary, so an assistant reply from a different turn that happens
  to repeat the same text is preserved.
- Only dedupe consecutive assistant rows within the same turn.

Co-Authored-By: Claude <[email protected]>
@fsdwen

fsdwen commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session-memory hook duplicates assistant messages when thinking is stripped

1 participant