Skip to content

fix(memory-lancedb): auto-capture stores OpenClaw's own [System] retry turns as user memories - #189956

Open
amittell wants to merge 7 commits into
openclaw:mainfrom
amittell:fix/memory-lancedb-skip-system-turns
Open

amittell wants to merge 7 commits into
openclaw:mainfrom
amittell:fix/memory-lancedb-skip-system-turns

Conversation

@amittell

@amittell amittell commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #189955

What Problem This Solves

Fixes: memory-lancedb auto-capture stores OpenClaw's own [System] turns as user memories when a stranded-reply retry, or a sessions_send restart note, quotes text that contains a capture trigger.

User Impact

User impact: with autoCapture on, only what the user said is stored. [System] rows already in a store stop coming back from recall and are no longer used for duplicate matching. They stay on disk and still show in openclaw ltm list.

Why This Change Was Made

Core marks the turns it writes itself with [System] through formatSystemTurnPrompt (src/sessions/system-turn-prompt.ts). On main 19aff5bfd42 its producers are the stranded-reply retry (src/auto-reply/reply/stranded-reply-recovery.ts), the transcript follow-up run (src/auto-reply/reply/transcript-followup-run.ts) and sessions_send (src/agents/tools/sessions-send-executor.ts). I have not shown that every internal turn goes through it. These turns are sent as user-role messages, so extractUserTextContent hands it to capture like any user text. Capture now goes through capturableUserText, which checks the raw turn for that marker before sanitizing, because sanitizing can remove the marker line along with a quoted context block. It then applies shouldCapture, which also rejects the marker. isRecallableMemoryText, which gates both recall and duplicate matching, skips such rows too. The marker is matched in the plugin because plugins cannot import the core helper, and a leading timestamp envelope is allowed before it.

Deleting rows already stored is left out. That is a retention change, and recall no longer surfaces them. One tradeoff: a user message that itself starts with [System] is no longer captured.

Evidence

Update 2026-11-25 (head ae07b96240c)

Merged main 9fb2059f340 as bfaa318c55d (clean; the branch was 8,755 commits behind) and pushed ae07b96240c on top. That commit fixes a dead-export failure this PR caused: check-deadcode-exports.mts --all flagged isSystemTurnPromptText (new) and shouldCapture (no longer imported by index.ts) in memory-policy.ts.

userTextForCapture(text) now returns undefined for a system turn, checked on the raw text before sanitizing, and otherwise the sanitized text. index.ts is back to main's loop: userTextForCapture, then shouldCapture. isSystemTurnPromptText is no longer exported.

  • The Knip production report passes. The scan still exits 1 on scripts/e2e/parallels/host-server.ts: detectParallelsHostIp and scripts/e2e/parallels/parallels-vm.ts: listVmNames; main's own scheduled CI fails the same way (run 45654340109 on 0b99555d5f7), and this PR touches nothing under scripts/.
  • Main still has the bug: on the merge bfaa318c55d, with main's memory-policy.ts, memory-capture-sanitization.ts and index.ts, the PR's test fails 3 of 4, and shouldCapture(strandedRetry) is true. No main commit has touched the PR's files since 9fb2059f340 (checked through 0f73e04b3f9).
  • Control for the new shape: removing only the raw-text check fails "auto-capture checks the raw turn before sanitizing can drop the marker line" (expected 'Remember the deployment window is Tue...' to be undefined).
  • memory-lancedb, each file twice: memory-policy 4/4, index 44/44, memory-capture-sanitization 28/28, auto-recall 2/2, auto-recall.deadline 3/3, recall-service 2/2. tsgo:extensions and tsgo:extensions:test pass, with a TS2322 control on each.
  • Test cost: memory-policy.test.ts --maxWorkers=1 at ae07b96240c, three runs: 8, 5 and 6 s wall (Vitest duration 6.04, 3.59 and 3.79 s). +60 net test lines.

Not re-run on this head: the QA scenario memory-lancedb-system-turn-capture. Main's catalog still loads it.

  • New qa scenario memory-lancedb-system-turn-capture (in this PR): real gateway, qa-channel, mock-openai, messages.visibleReplies: message_tool, memory-lancedb autoCapture: true.
    • The first prompt is not capturable, so the [System] retry is the first capturable text. A later turn in the same conversation, QA-MEMORY-BARRIER 記住 ..., must be stored before the store is read; captures for one session run in order, so the retry's capture has settled by then.
    • It fails if any stored row contains the retry's send it now with message(action=send) instruction, so it catches the retry whether or not its [System] line survived.
    • With main's memory-lancedb at eef407423d4: fails after the barrier settles, with [System] Your previous reply was not delivered because you did not call message(action=send). Your reply text was: "QA-STRANDED-85714:...". If the user should see a reply, send it now with message(action=send). If no reply is needed, answer exactly NO_REPLY. stored. The gateway logs two auto-captured 1 memories: the retry turn and the barrier.
    • This branch at f517e265d7f: passes with barrier rows=1; retry rows=0.
    • Command: node scripts/run-node.mjs qa suite --provider-mode mock-openai --scenario memory-lancedb-system-turn-capture --concurrency 1 --fast, after pnpm build.
    • CI does not run this scenario: no smoke profile selects it, and it appears 0 times in the QA Smoke logs for this head. The gateway results above are my local runs.
  • pnpm test extensions/memory-lancedb/memory-policy.test.ts --maxWorkers=1: 4 passed.
    • Control with memory-policy.ts from main: expected true to be false on shouldCapture(strandedRetry), and recall returned ['stored', 'user'].
    • The context-block case: under the sanitize-first order, the retry text sanitizes to Remember the deployment window is Tuesdays.". If the user should see a reply, send it now with message(action=send). ... and shouldCapture returns true. capturableUserText returns undefined for it.
    • Through the stranded retry, the gateway does not let that case through. With a temporary mock fixture whose private final opened with Sender: ⟦openclaw:ctx⟧ and a fenced JSON block, main stored [System] ... Your reply text was: "Remember the deployment window is Tuesdays. QA-STRANDED-85714... with the block already removed and the [System] line intact. The first commit on this branch (sanitize, then check) passed that run. The raw-turn check is defense for other system-turn producers, so the fixture is not in this PR.
  • All 21 memory-lancedb test files except the live one: 174 passed, 0 failed.
  • pnpm tsgo:all exits 0. oxlint and oxfmt are clean on the changed files.
  • Test lines: main's test-line ratchet is now at its ceiling (3855c896edd: slack 0), so dcf76a14600 adds config/test-lines-allocations/189956-memory-capture-skip-system-turns.txt with this PR's exact net test-line growth, 62 lines. They are the tests that pin this change: Memory auto-capture skips OpenClaw's own [System] retry turns. Merged onto 3855c896edd, check-test-lines-ratchet.mts --base 3855c896edd --no-merge-base reads Test lines OK: 6592430; ceiling: 6592430; slack: 0., and an allocation of 63 is refused.
  • Test cost (pnpm test <file> --maxWorkers=1, Bun, the local default, macOS arm64, two runs each): memory-policy.test.ts 2.7 s and 1.5 s wall, 39 ms and 18 ms of tests. CI run 41271447272, Bun: memory-policy.test.ts 30 ms of tests in a shared run (checks-node-changed-extensions-bundle-1).
  • Gap: the unit tests copy core's marker and retry text, because extension tests do not import core. The qa scenario is the end-to-end check against core's real prompt.

…apture

Core writes stranded-reply retries, restart-recovery notes and transcript
follow-ups as user-role turns prefixed with [System] (formatSystemTurnPrompt).
memory-lancedb's agent_end capture treats them like any user text, so a retry
that quotes a reply containing a trigger word ("remember", "always", or a
custom trigger) was stored as a user memory and could be recalled later.

shouldCapture now rejects text that starts with the marker. isRecallableMemoryText,
which gates both recall and duplicate matching, skips rows already stored. The
marker is matched in the plugin because plugins cannot import the core helper.
Stored rows are not deleted.

Adds the qa scenario memory-lancedb-system-turn-capture: a real gateway with
message_tool replies and the mock provider. It fails on main with the [System]
row stored and passes with this change.
Copilot AI balanced review requested due to automatic review settings November 1, 2026 01:54
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T01:58:15.612970Z f0774da PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Sanitization can strip the system-turn marker and allow unintended capture, while the retry test can pass before background capture completes.

2 open issues
What changed in this PR

Prevents memory-lancedb from treating OpenClaw-generated [System] turns as user memories, addressing #189955 without deleting existing stored rows.

Changes:

  • Rejects system-prefixed text during capture, recall, and duplicate matching.
  • Adds unit coverage for retry turns, restart notes, and previously stored system rows.
  • Adds a QA scenario exercising stranded-reply recovery with auto-capture enabled.
File Description
qa/​scenarios/​memory/​memory-lancedb-system-turn-capture.yaml Exercises recovery and checks that user text—but not system turns—is stored.
extensions/​memory-lancedb/​memory-policy.ts Filters system-prefixed text from capture, recall, and duplicate matching.
extensions/​memory-lancedb/​memory-policy.test.ts Tests system-turn rejection and preservation of ordinary user memories.

Review effort: Balanced

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Exclude OpenClaw-generated [System] turns from automatic memory capture, recall, and duplicate matching.

Example: A stranded-reply retry quotes “I'll remember that the deploy window is Tuesdays.”

  • Before: The retry instructions can be stored and later recalled as a user memory.
  • After: The retry is skipped, while the user's own capturable message remains eligible.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, worthwhile repair with production-path proof and no identified defects; required exact-head CI remains awaiting execution approval.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied built-Gateway QA run exercises the actual retry producer, registered capture hook, embeddings transport, and LanceDB CLI query with mock-openai, recording a failing base and barrier rows=1/retry rows=0 after the fix; subsequent changes preserve that scenario and report focused validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: OpenClaw's retry instructions are remembered and recalled as facts supplied by the user.
Reason: The repair restores the existing separation between user memory and host-generated context without adding configuration or deleting data.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR fixes a current LanceDB memory-contamination bug, preserves existing storage, and addresses both earlier findings; no new correctness defects were found.

Reviewed head: 6f1e8dcd169b18e04be6cd58963dc672f252a2c7

Before merge

  • Await maintainer action - Approve the pending workflow execution for the reviewed head and let required CI complete.

Findings

None.

Agent review details

How this fits together

The LanceDB plugin receives user-role transcript messages after agent runs, filters and embeds capturable text, and filters stored search results before recall or duplicate matching.

flowchart TD
  A[User and internal turns] --> B[Agent end hook]
  B --> C[Raw system marker check]
  C --> D[Sanitization and capture policy]
  D --> E[LanceDB store]
  E --> F[Shared recall filter]
  F --> G[Recall and duplicate matching]
Loading

Technical review

Best possible solution:

Land the focused plugin policy repair once the required exact-head workflows complete successfully.

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

The core retry formatter and current-main capture loop establish the failure path, corroborated by the author's recorded failing Gateway run; this read-only review executed no target code.

Is this the best way to solve the issue?

The change uses the existing capture and recall owners, rejects the marker before sanitization can erase it, and preserves stored rows; the documented limitation is that user-authored text beginning with [System] is also excluded.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 18e53d806dbb.

Provenance checked

  • Capture sanitization and contaminated-memory filtering keeps the original intent (945faf8: Exclude transport metadata from durable user memory and recalled context; the later module split preserved this plugin-owned boundary.)
  • Ordered automatic capture keeps the original intent (e41d2b7: Preserve capture progress through compaction and serialize capture and cleanup; the new scenario relies on that existing ordering without changing it.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a72ff7a adds extensions/memory-lancedb/memory-policy.ts:247 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a72ff7a93fb1; files: extensions/memory-lancedb/memory-policy.ts)
  • Markus Hartung: Raw commit e41d2b7 adds extensions/memory-lancedb/index.ts:575 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e41d2b7e51bf; files: extensions/memory-lancedb/index.ts)

PR surface

Source +29, Tests +60, Other +136. Total +225 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 34 5 +29
Tests 1 61 1 +60
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 136 0 +136
Total 6 231 6 +225

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: same_root_cause
Canonical: #189955
Summary: This PR supplies the LanceDB repair for the linked report; the Claude CLI report concerns a separate transcript-import consumer.

Members:

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

Labels

Label changes:

  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on maintainer.

Label justifications:

  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-01T02:08:59.701Z sha f0774da :: needs real behavior proof before merge. :: [P2] Reject system turns before sanitization removes their prefix | [P2] Wait for retry capture completion before checking absence
  • reviewed 2026-11-01T04:06:34.730Z sha f517e26 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-25T23:31:10.450Z sha ae07b96 :: passed. :: none

Reviewed November 27, 2026, 1:32 PM ET / 18:32 UTC (Revision 4).

… the scenario on a barrier

Sanitizing can drop the [System] line itself: when a stranded-reply retry quotes
a reply that opens with a context block, MARKER_JSON_BLOCK_RE removes the
whole first line, and the "Remember ..." sentence that follows was captured.
Capture now goes through capturableUserText, which checks the raw turn for the
marker (after any leading timestamp envelope) before sanitizing, then applies
shouldCapture as before.

The qa scenario no longer sleeps a fixed 8 s. It sends a later capturable turn
in the same conversation and waits for that row. Captures for one session run
in order, so the retry's capture has finished when the row appears. The first
prompt is not capturable, so no earlier row can absorb the retry turn through
duplicate matching. The barrier text sits far below the 0.95 duplicate
threshold under the mock's 16-dimension embeddings.
… qa scenario

The scenario now looks for any stored row that contains the retry turn's
"send it now with message(action=send)" instruction, so it also catches a
retry whose [System] first line was removed before storage.
@amittell

amittell commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Both P2s are addressed at f517e265d7f, and the Evidence section is updated. The raw turn is checked before sanitizing, and the scenario reads the store only after a later same-session capture has landed.

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Nov 1, 2026
amittell added a commit to amittell/openclaw that referenced this pull request Nov 11, 2026
Upstream head dcf76a1. It replaces the capture and recall half of
the fork's f2c2804 ("keep OpenClaw system-turn prompts out of
memory"), which covered the same behaviour: shouldCapture rejects text
starting with [System], and recall and duplicate matching skip it.
Upstream is reviewing the PR's version, so it becomes the one owner.
The PR adds two things the fork lacked:
- capturableUserText checks the raw turn for the marker before
  sanitizing. The fork sanitized first, so a stranded-reply retry that
  quotes a context block lost its [System] line with the block and
  stored "Remember ..." as a user memory.
- isSystemTurnPromptText allows a leading timestamp envelope before
  the marker.

Changes against the branch:
- memory-policy.ts: the PR's isSystemTurnPromptText, the
  isRecallableMemoryText comment and capturableUserText.
- memory-capture-sanitization.ts: the fork's isSystemTurnPromptText is
  removed; the PR's stripLeadingTimestampPrefix is added.
- index.ts: the capture loop goes through capturableUserText.
- memory-policy.test.ts: the PR's, unchanged.
- extensions/memory-lancedb/system-turn-capture.test.ts (fork) is
  removed: the PR's memory-policy tests make the same assertions
  (capture rejects the restart and retry turns, the same words from the
  user are captured, a timestamped turn is rejected, stored rows leave
  recall) and add the raw-before-sanitize and duplicate cases.

Kept from the fork, because the PR does not do them:
- memory-lancedb-system-turn-rows, the doctor-only migration that
  deletes stored [System] rows (the PR leaves deletion out as a
  retention change). doctor-contract-api.ts now imports the PR's
  predicate from memory-policy.ts, so capture, recall and deletion
  match one predicate; deletion now also matches a row whose [System]
  marker follows a timestamp envelope, as recall already skips it.
- test/memory-lancedb-system-turn-capture.test.ts and the index.ts
  re-export it uses: it runs core's real formatSystemTurnPrompt through
  the plugin, so CI catches marker drift. The PR's unit tests copy the
  marker, and its qa scenario is not in any CI profile.
- docs/plugins/memory-lancedb.md already describes this behaviour.

Dropped: the PR's qa scenario memory-lancedb-system-turn-capture. It
fails on this branch before reaching its assertions. Run on the M4
after pnpm build (mock-openai, --concurrency 1 --fast): "timed out
after 180000ms" twice, at the wait for the delivered reply. Here the
embedded runner's silent-stop nudge (incomplete-turn-recovery.ts,
SILENT_STOP_DELIVERY_RETRY_INSTRUCTION, fork-only) answers the stranded
final first. The mock only calls message(action=send) for core's
stranded retry text ("you did not call message(action=send)"), so the
reply is never delivered, core's [System] retry never reaches the model
(2 provider requests per attempt), and the barrier turn is never sent.

test-lines allocation: carried, with the count set to this tree's net
test-line change (11: +62 in memory-policy.test.ts, -51 for the removed
fork test).

Proof (M4, Node 26.12.1, --maxWorkers=1):
- All 23 memory-lancedb test files except the live one and the root
  test/memory-lancedb-system-turn-capture.test.ts: passed, in a run
  that also had qa-lab's scenario-catalog.test.ts and
  coverage-report.test.ts with the scenario present (26 files, 239
  tests, shards 1 + 62 + 130 + 46). Dropping the scenario changes no
  other file.
- Red-before, the four source files restored to the fork variant:
  memory-policy.test.ts 2 failed, 2 passed of 4. The two failures are
  isSystemTurnPromptText and capturableUserText missing from
  memory-policy.ts; the recall and duplicate case passes, because the
  fork already skipped those rows.
- Red-before, capturableUserText with the fork's sanitize-first order
  (the raw-turn check removed): the context-block case fails with
  "expected 'Remember the deployment window is Tue...' to be undefined"
  (1 failed, 3 passed of 4). That is the retry the fork stored.
amittell added a commit to amittell/openclaw that referenced this pull request Nov 11, 2026
…ear its stored memories

The embedded runner's silent-stop delivery nudge (fork-only,
incomplete-turn-recovery.ts) is a user-role turn OpenClaw writes
itself, but unlike the fork's stalled-turn, stranded-reply and
goal-continuation prompts it was not built with formatSystemTurnPrompt.
Its "never" matches memory-lancedb's capture triggers, so with
autoCapture on it was stored as a user memory: the openclaw#189956 capture
check on this branch returns the nudge text unchanged, and the qa run
of that PR's scenario logged "auto-captured 1 memories" right after the
nudge fired. Each bot's store holds one such row (mac-mini written
2026-10-27, rh-bot 2026-08-20), as measured by the carry lead.

- SILENT_STOP_DELIVERY_RETRY_INSTRUCTION is now
  formatSystemTurnPrompt(<same text>), so it starts with [System] and the
  carried capture check and recall skip it. Its users
  (terminal-resolution.ts and two tests) read the constant; no test or
  snapshot pins the text.
- memory-lancedb-system-turn-rows, the fork's doctor-only cleanup, also
  deletes rows whose text is exactly the legacy unmarked nudge. The
  text has not changed since upgrade-v2026.7.2. Exact match only: a row
  that starts the same way and then differs is kept. The rows already
  stored go when the deploy runs Doctor (doctor --fix), after the
  database backup; startup never runs this cleanup.
- The plugin entry's fork re-export for the root test adds
  capturableUserText, the capture check itself.

Proof (M4, Node 26.12.1, --maxWorkers=1):
- The root test, doctor-contract-api.test.ts, memory-policy.test.ts and
  the 15 embedded-runner test files that import incomplete-turn-recovery
  or terminal-resolution (including
  run.plugin-runtime-refresh.integration.test.ts): 18 files, 231 tests
  passed.
- Red-before, the wrap and the cleanup reverted: the root test's new
  case fails (capturableUserText returns the nudge text), 1 failed of 2.
  With only the cleanup reverted, doctor-contract-api.test.ts fails on
  "delete 2" for "delete 3" (1 failed, 6 passed of 7).
- Mutation: matching the nudge by prefix instead of exactly deletes the
  near-miss row too, and the same test fails on "delete 4".
- tsgo:core, tsgo:extensions, tsgo:core:test, tsgo:extensions:test and
  tsgo:test:root rc=0; oxfmt --check and oxlint on the five files rc=0;
  check-line-cap-ratchet and check-test-mock-exports with --base the
  v2026.11.2 tag rc=0; prompt:snapshots:check rc=0 (7 files current).
…e rules

pnpm deadcode:report flagged isSystemTurnPromptText and shouldCapture:
once index.ts called capturableUserText, both exports had only test
importers.

userTextForCapture now only drops OpenClaw system turns, checked on the
raw text before sanitizing, and returns the sanitized user text. index.ts
runs shouldCapture on that text as main does, so shouldCapture keeps its
production consumer and isSystemTurnPromptText becomes module-private.
@amittell

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Merged main 9fb2059f340 as bfaa318c55d (clean; the branch was 8,755 commits behind) and pushed ae07b96240c on top. That commit fixes a dead-export failure this PR caused: check-deadcode-exports.mts --all flagged isSystemTurnPromptText (new) and shouldCapture (no longer imported by index.ts) in memory-policy.ts.

userTextForCapture(text) now returns undefined for a system turn, checked on the raw text before sanitizing, and otherwise the sanitized text. index.ts is back to main's loop: userTextForCapture, then shouldCapture. isSystemTurnPromptText is no longer exported.

  • The Knip production report passes. The scan still exits 1 on scripts/e2e/parallels/host-server.ts: detectParallelsHostIp and scripts/e2e/parallels/parallels-vm.ts: listVmNames; main's own scheduled CI fails the same way (run 45654340109 on 0b99555d5f7), and this PR touches nothing under scripts/.
  • Main still has the bug: on the merge bfaa318c55d, with main's memory-policy.ts, memory-capture-sanitization.ts and index.ts, the PR's test fails 3 of 4, and shouldCapture(strandedRetry) is true. No main commit has touched the PR's files since 9fb2059f340 (checked through 0f73e04b3f9).
  • Control for the new shape: removing only the raw-text check fails "auto-capture checks the raw turn before sanitizing can drop the marker line" (expected 'Remember the deployment window is Tue...' to be undefined).
  • memory-lancedb, each file twice: memory-policy 4/4, index 44/44, memory-capture-sanitization 28/28, auto-recall 2/2, auto-recall.deadline 3/3, recall-service 2/2. tsgo:extensions and tsgo:extensions:test pass, with a TS2322 control on each.
  • Test cost: memory-policy.test.ts --maxWorkers=1 at ae07b96240c, three runs: 8, 5 and 6 s wall (Vitest duration 6.04, 3.59 and 3.79 s). +60 net test lines.

Not re-run on this head: the QA scenario memory-lancedb-system-turn-capture. Main's catalog still loads it.

@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

# Conflicts:
#	extensions/memory-lancedb/memory-policy.ts
@amittell

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Merged main 6deafbdf9dc as 6f1e8dcd169. Main's #196265 moved DEFAULT_CAPTURE_MAX_CHARS, DEFAULT_RECALL_MAX_CHARS and MemoryCategory from ./config.js to ./memory-policy-data.js; the memory-policy.ts imports now take them from there and keep this PR's sanitizeForMemoryCapture and stripLeadingTimestampPrefix. memory-policy.test.ts, index.test.ts and memory-capture-sanitization.test.ts: 76 tests pass. tsgo:extensions and tsgo:extensions:test pass with 0 errors (an injected TS2322 in memory-policy.ts fails tsgo:extensions), and oxlint is clean on the PR's files.

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 27, 2026

This branch has not been deployed

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

Labels

extensions: memory-lancedb Extension: memory-lancedb extensions: qa-lab 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: M status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: memory-lancedb auto-capture stores OpenClaw's own [System] retry turn as a user memory

2 participants