Skip to content

fix(session-memory): skip transcript-only assistant rows#95820

Open
moeedahmed wants to merge 2 commits into
openclaw:mainfrom
moeedahmed:fix/session-memory-skip-delivery-mirror
Open

fix(session-memory): skip transcript-only assistant rows#95820
moeedahmed wants to merge 2 commits into
openclaw:mainfrom
moeedahmed:fix/session-memory-skip-delivery-mirror

Conversation

@moeedahmed

@moeedahmed moeedahmed commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session-memory summaries can duplicate assistant replies when a transcript contains both the real provider assistant message and an OpenClaw-authored bookkeeping assistant row with identical visible text, such as delivery-mirror or gateway-injected.

Dropping every OpenClaw-authored assistant row is unsafe, because standalone message-tool delivery mirrors and non-duplicate gateway-injected replies can be the only visible assistant text. This PR now drops only duplicate bookkeeping rows and preserves unique visible assistant replies.

Summary

  • skips OpenClaw delivery-mirror and gateway-injected assistant rows only when their sanitized text repeats the previous visible assistant reply
  • preserves standalone delivery-mirror replies and non-duplicate gateway-injected assistant text
  • resets duplicate comparison on new user turns so later standalone mirrors are not incorrectly dropped
  • adds regression coverage for duplicate dropping and unique-row preservation

Evidence

  • node scripts/run-vitest.mjs run src/hooks/bundled/session-memory/handler.test.ts src/hooks/bundled/session-memory/transcript.test.ts passed: 2 files, 35 tests
  • corepack pnpm exec oxfmt --check --threads=1 src/hooks/bundled/session-memory/transcript.ts src/hooks/bundled/session-memory/handler.test.ts passed
  • git diff --check origin/main...HEAD passed
  • GitHub Real behavior proof check passed on the refreshed head

Real transcript-reader proof using getRecentSessionContent against a temporary JSONL transcript containing:

  • a real provider assistant reply
  • a duplicate delivery-mirror row
  • a duplicate gateway-injected row
  • a non-duplicate gateway-injected row

Output:

user: Summarise the plan
assistant: Plan ready.
assistant: Follow-up sent.

The duplicate OpenClaw-authored bookkeeping rows are omitted, while the unique gateway-injected assistant reply is retained.

Context

Raw transcripts can include both a real assistant response and OpenClaw-authored assistant bookkeeping rows. Session-memory should not duplicate the same assistant text, but it must still preserve OpenClaw-authored assistant rows when they are the only visible reply.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 22, 2026
@moeedahmed
moeedahmed force-pushed the fix/session-memory-skip-delivery-mirror branch from 0e3fc4f to e9850db Compare June 22, 2026 16:03
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 22, 2026
@clawsweeper

clawsweeper Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 12, 2026, 4:02 AM ET / 08:02 UTC.

Summary
The PR expands session-memory duplicate filtering from delivery-mirror rows to all classified transcript-only OpenClaw assistant rows while preserving unique visible replies and adding regression coverage.

PR surface: Source 0, Tests +112. Total +112 across 2 files.

Reproducibility: yes. Current main only deduplicates delivery-mirror rows, so a provider assistant row followed by an identical gateway-injected row remains a concrete source-level duplicate path.

Review metrics: 1 noteworthy metric.

  • Session-memory predicate: 1 widened. The retention check expands from delivery-mirror-only to both models in the shared transcript-only OpenClaw assistant classification.

Stored data model
Persistent data-model change detected: serialized state: src/hooks/bundled/session-memory/handler.test.ts, serialized state: src/hooks/bundled/session-memory/transcript.ts, unknown-data-model-change: src/hooks/bundled/session-memory/handler.test.ts, unknown-data-model-change: src/hooks/bundled/session-memory/transcript.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #95820
Summary: This PR is the open narrow candidate for the gateway-injected remainder of the duplicate session-memory projection bug.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Refresh or rerun exact-head CI after the unrelated localization baseline repair on current main is included.

Risk before merge

  • [P1] Merging intentionally removes an immediately repeated gateway-injected row from session-memory output, so an unusual workflow that treats identical consecutive injected text as distinct events would lose that event distinction in the memory projection.

Maintainer options:

  1. Accept the narrow projection change (recommended)
    Land the duplicate-only filter after exact-head gates pass, accepting that session memory represents visible reply text rather than repeated bookkeeping events.
  2. Require event-distinction proof
    Pause until a producer-level scenario demonstrates whether identical consecutive gateway-injected rows can represent separate user-relevant events.

Next step before merge

  • No automated repair is needed; this PR should proceed through normal maintainer review and refreshed exact-head merge gates.

Security
Cleared: The diff changes only transcript projection logic and regression tests, with no concrete security or supply-chain concern found.

Review details

Best possible solution:

Keep this PR open until a linked canonical PR proves it covers this PR's unique work, or a maintainer confirms closure.

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

Yes. Current main only deduplicates delivery-mirror rows, so a provider assistant row followed by an identical gateway-injected row remains a concrete source-level duplicate path.

Is this the best way to solve the issue?

Yes. Reusing the shared transcript-only classification while dropping only immediate sanitized duplicates is narrower than general assistant-text deduplication and preserves unique injected replies.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 55679d88c6be.

Label changes

Label changes:

  • add merge-risk: 🚨 session-state: The PR changes which assistant transcript rows survive into persisted session-memory summaries.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from the real transcript reader showing duplicate bookkeeping rows removed and unique gateway-injected text retained.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal output from the real transcript reader showing duplicate bookkeeping rows removed and unique gateway-injected text retained.

Label justifications:

  • P2: This is a bounded session-memory correctness fix with limited blast radius.
  • merge-risk: 🚨 session-state: The PR changes which assistant transcript rows survive into persisted session-memory summaries.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal output from the real transcript reader showing duplicate bookkeeping rows removed and unique gateway-injected text retained.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from the real transcript reader showing duplicate bookkeeping rows removed and unique gateway-injected text retained.
Evidence reviewed

PR surface:

Source 0, Tests +112. Total +112 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 8 0
Tests 1 112 0 +112
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 120 8 +112

What I checked:

Likely related people:

  • SunnyShu0925: Authored the merged delivery-mirror duplicate filter that this PR narrowly extends. (role: introduced current behavior; confidence: high; commits: 79a20accca90, 28cbe0024711; files: src/hooks/bundled/session-memory/transcript.ts, src/hooks/bundled/session-memory/handler.test.ts)
  • sallyom: Merged the existing session-memory duplicate fix and is connected to the current projection behavior. (role: merger; confidence: medium; commits: 1052652a7168; files: src/hooks/bundled/session-memory/transcript.ts, src/hooks/bundled/session-memory/handler.test.ts)
  • Peter Steinberger: Introduced the gateway transcript append helper that owns the gateway-injected assistant rows affected by this projection. (role: introduced adjacent behavior; confidence: high; commits: 142c0a7f7d0c; files: src/gateway/server-methods/chat-transcript-inject.ts)
  • vincentkoc: Recently established the shared transcript-only OpenClaw assistant classification reused by this branch. (role: recent area contributor; confidence: medium; commits: b3fb295e9410; files: src/shared/transcript-only-openclaw-assistant.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (2 earlier review cycles)
  • reviewed 2026-07-07T02:43:06.028Z sha 29d2f6c :: needs maintainer review before merge. :: none
  • reviewed 2026-07-07T04:10:08.444Z sha d5ad3e6 :: needs maintainer review before merge. :: none

@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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 23, 2026
@moeedahmed
moeedahmed force-pushed the fix/session-memory-skip-delivery-mirror branch from e9850db to d5ad3e6 Compare June 29, 2026 17:27
@moeedahmed

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 29, 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.

@moeedahmed

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. and removed 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. P1 High-priority user-facing bug, regression, or broken workflow. labels Jun 29, 2026
@moeedahmed
moeedahmed force-pushed the fix/session-memory-skip-delivery-mirror branch from 29d2f6c to d5ad3e6 Compare July 7, 2026 03:23
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 12, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 12, 2026
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant