Skip to content

fix(memory): bound LanceDB prompts and reload embedding config - #125567

Merged
steipete merged 2 commits into
mainfrom
steipete/bounded-memory-and-hot-reload-9aab48
Aug 18, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/bounded-memory-and-hot-reload-9aab48

Conversation

@steipete

@steipete steipete commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes two memory-lancedb failures that persisted across sessions and hot configuration updates. A memory written through memory_store could be arbitrarily large, so one legacy or tool-stored row could dominate recall output and automatic prompt injection. Separately, rotating the plugin's embedding credential or endpoint at runtime left the register-time client active until the Gateway restarted.

Why This Change Was Made

The plugin now rejects memory_store text above the live captureMaxChars limit before embedding or persistence, and bounds each escaped model-visible recalled item with the live recallMaxChars limit across explicit recall, automatic recall, and forget confirmations. Stored rows and structured recall details remain unchanged.

Embedding calls now carry the validated live connection settings into the embedding owner. embedding.apiKey and embedding.baseUrl rotate live, while provider, model, and dimensions remain startup-stable because they define the persisted LanceDB vector-index identity. Provider-backed clients reuse the existing per-agent retirement lifecycle so admitted work drains before stale providers close and replacements start.

User Impact

Oversized memories can no longer silently inflate future prompts, and existing oversized rows are shown only within the configured recall bound. Operators can rotate a leaked embedding key or move the same embedding identity to another endpoint and have the next memory operation use it without restarting the Gateway. Provider, model, or dimension changes require a planned LanceDB re-embedding/rebuild before restart; the plugin does not rewrite existing vectors automatically.

Evidence

  • Pre-fix regressions reproduced the reported failures: oversized memory_store completed instead of rejecting, recall/auto-recall leaked the oversized tail, and runtime key/endpoint changes kept using the old client.
  • node scripts/run-vitest.mjs extensions/memory-lancedb/index.test.ts extensions/memory-lancedb/embeddings.lifecycle.test.ts extensions/memory-lancedb/memory-cli.test.ts extensions/memory-lancedb/lancedb-store.test.ts — 163 tests passed.
  • pnpm test:extension memory-lancedb — 187 tests passed.
  • pnpm docs:check-mdx && pnpm docs:check-links — passed with 0 broken links.
  • node scripts/check-changed.mjs -- docs/plugins/memory-lancedb.md extensions/memory-lancedb/config.ts extensions/memory-lancedb/embeddings.lifecycle.test.ts extensions/memory-lancedb/embeddings.ts extensions/memory-lancedb/index.test.ts extensions/memory-lancedb/index.ts extensions/memory-lancedb/lancedb-store.test.ts extensions/memory-lancedb/memory-cli.test.ts extensions/memory-lancedb/memory-cli.ts extensions/memory-lancedb/memory-policy.ts extensions/memory-lancedb/openclaw.plugin.json — passed.
  • Real OpenAI SDK loopback probe verified that consecutive requests after a live config rotation used the old then new API key and base URL respectively.
  • Native LanceDB regression verifies an existing fixed-size vector table rejects a different query dimension, protecting the startup-stable index-identity policy.
  • Fresh autoreview reported no accepted/actionable findings after both implementation rounds.
  • Production/metadata: +156/-54 (net +102). Tests: +346/-58 (net +288). Docs: +26/-12 (net +14).
  • AI-assisted: yes; the final diff was independently reviewed and behavior-validated.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 18, 2026 03:48
@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-lancedb Extension: memory-lancedb size: L maintainer Maintainer-authored PR labels Aug 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 1:35 AM ET / 05:35 UTC.

ClawSweeper review

What this changes

The PR bounds LanceDB memory text shown to the model, rejects oversized manual memory writes, and refreshes embedding credentials or endpoints for subsequent memory operations without restarting the Gateway.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this active maintainer PR open. The revised head addresses the prior index-identity blocker by applying only live credential/endpoint changes while retaining the startup provider, model, and dimensions; no blocking patch defect was found. It remains behind current main with exact-head checks incomplete.

Priority: P2
Reviewed head: 2eb424253ea508ad462d263bf3d6cc63e3606692

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch cleanly resolves the prior index-identity finding with focused regression coverage and documentation; rebase and exact-head CI remain before landing.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported loopback probe is supportive but no artifact was available for inspection.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported loopback probe is supportive but no artifact was available for inspection.
Evidence reviewed 8 items Current-main behavior: Current main constructs embeddings once during plugin registration, so later operations keep the startup connection settings; recalled tool output also escaped but did not bound each returned memory.
Owner-boundary repair: The head resolves live config per operation, preserves startup provider/model/dimensions for the vector index, and passes the resulting embedding config through every recall and capture path.
Prompt bound: A shared formatter escapes and UTF-16-safely truncates every model-visible recalled memory, including automatic recall context.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw plugins list

Result: PASS (completed)

│                                          │                        │          │          │ Inworld streaming text-to-speech (MP3, OGG_OPUS, PCM    │          │
│                                          │                        │          │          │ telephony).                                             │          │
│ @openclaw/irc                            │ irc                    │ openclaw │ disabled │ ~/work/clawsweeper/cla...xtensions/irc/index.ts         │ 2026.8.1 │
│ @openclaw/kilocode-provider              │ kilocode               │ openclaw │ enabled  │ ~/work/clawsweeper/cla...ions/kilocode/index.ts         │ 2026.8.1 │
│ @openclaw/kimi-provider                  │ kimi                   │ openclaw │ enabled  │ ~/work/clawsweeper/cla...s/kimi-coding/index.ts         │ 2026.8.1 │
│ LongCat                                  │ longcat                │ openclaw │ enabled  │ ~/work/clawsweeper/cla...sions/longcat/index.ts         │ 2026.8.1 │
│                                          │                        │          │          │ OpenClaw LongCat provider plugin.                       │          │
│ @openclaw/mattermost                     │ mattermost             │ openclaw │ disabled │ ~/work/clawsweeper/cla...ns/mattermost/index.ts         │ 2026.8.1 │
│ @openclaw/meta-provider                  │ meta                   │ openclaw │ enabled  │ ~/work/clawsweeper/cla...tensions/meta/index.ts         │ 2026.8.1 │
│ @openclaw/mistral-provider               │ mistral                │ openclaw │ enabled  │ ~/work/clawsweeper/cla...sions/mistral/index.ts         │ 2026.8.1 │
│ @openclaw/moonshot-provider              │ moonshot               │ openclaw │ enabled  │ ~/work/clawsweeper/cla...ions/moonshot/index.ts         │ 2026.8.1 │
│ MXC Sandbox Execution                    │ mxc                    │ openclaw │ disabled │ ~/work/clawsweeper/cla...xtensions/mxc/index.ts         │ 2026.8.1 │
│                                          │                        │          │          │ OS-level sandboxed tool execution via MXC: runs         │          │
│                                          │                        │          │          │ commands in a Windows ProcessContainer with configured  │          │
│                                          │                        │          │          │ MXC policy files.                                       │          │
│ @openclaw/novita-provider                │ novita                 │ openclaw │ enabled  │ ~/work/clawsweeper/cla...nsions/novita/index.ts         │ 2026.8.1 │
│ @openclaw/opencode-provider              │ opencode               │ openclaw │ enabled  │ ~/work/clawsweeper/cla...ions/opencode/index.ts         │ 2026.8.1 │
│ OpenShell Sandbox                        │ openshell              │ openclaw │ disabled │ ~/work/clawsweeper/cla...ons/openshell/index.ts         │ 2026.8.1 │
│                                          │                        │          │          │ OpenClaw sandbox backend for the NVIDIA OpenShell CLI   │          │
│                                          │                        │          │          │ with mirrored local workspaces and SSH command          │          │
│                                          │                        │          │          │ execution.                                              │          │
│ @openclaw/parallel-plugin                │ parallel               │ openclaw │ disabled │ ~/work/clawsweeper/cla...ions/parallel/index.ts         │ 2026.8.1 │
│ @openclaw/perplexity-plugin              │ perplexity             │ openclaw │ disabled │ ~/work/clawsweeper/cla...ns/perplexity/index.ts         │ 2026.8.1 │
│ PixVerse                                 │ pixverse               │ openclaw │ enabled  │ ~/work/clawsweeper/cla...ions/pixverse/index.ts         │ 2026.8.1 │
│                                          │                        │          │          │ OpenClaw PixVerse vi
… output truncated …

Assertions:

  • PASS expect_output: memory-lancedb

How this fits together

The LanceDB memory plugin embeds stored memories and returns recalled text to memory tools or automatic prompt injection. Live plugin config feeds the embedding client, while the persisted LanceDB vector table requires a stable semantic identity.

flowchart LR
  A[Memory tools and hooks] --> B[Live plugin configuration]
  B --> C[Memory bounds and identity check]
  C --> D[Embedding client or provider]
  D --> E[LanceDB vector table]
  E --> F[Recall results]
  F --> G[Tool response or model context]
Loading

Before merge

  • Resolve merge risk (P1) - Merging changes the behavior of existing embedding key and endpoint settings; the code and docs preserve startup-stable provider/model/dimensions, but the branch is behind main and exact-head CI must re-confirm that compatibility boundary.
  • Resolve merge risk (P1) - The PR adds net 102 production lines for shared recall formatting and live embedding lifecycle ownership; the centralization is justified, but rebase review should keep unrelated growth out of the final merge.
  • Resolve merge risk (P1) - The local checkout has no installed OpenAI SDK source, so its existing constructor contract could not be independently reread; the patch reuses the current-main client construction and the PR reports a loopback probe.
  • Complete next step (P2) - No repair lane is needed: the revised head addresses the prior finding; normal rebase and exact-head CI review remain.
Agent review details

Security

None.

PR surface

Source +102, Tests +288, Docs +14. Total +404 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 156 54 +102
Tests 4 346 58 +288
Docs 1 26 12 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 528 124 +404

Review metrics

Metric Value Why it matters
Production versus test delta production +156/-54 (net +102); tests +346/-58 (net +288); docs +26/-12 (net +14) The production growth implements a shared model-visible bound and connection-lifecycle ownership; most added coverage is focused regression proof.
Embedding configuration behavior 2 existing fields live-reloaded; 3 identity fields retained at startup This is the compatibility boundary that protects persisted LanceDB vectors while enabling key and endpoint rotation.

Stored data model

Persistent data-model change detected: serialized state: extensions/memory-lancedb/embeddings.ts, serialized state: extensions/memory-lancedb/lancedb-store.test.ts, unknown-data-model-change: extensions/memory-lancedb/embeddings.lifecycle.test.ts, unknown-data-model-change: extensions/memory-lancedb/embeddings.ts, unknown-data-model-change: extensions/memory-lancedb/index.test.ts, unknown-data-model-change: extensions/memory-lancedb/index.ts, and 10 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Rebase and verify the upgrade boundary (recommended)
    Refresh the branch against current main and require exact-head CI to confirm that key and endpoint rotation remains live while provider, model, and dimensions stay startup-stable.

Technical review

Best possible solution:

Keep prompt bounds in the shared memory-policy formatter and connection rotation in the embedding owner, while retaining startup vector identity until an explicit rebuild path exists.

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

Yes, from source: current main builds the embedding client once at registration and emits unbounded recalled rows, while the head routes each operation through live config and a shared output bound. The read-only review did not execute the reported runtime probe.

Is this the best way to solve the issue?

Yes. The patch fixes the producer and presentation owners rather than rebuilding the database or adding a downstream guard, and it explicitly blocks live semantic-index changes that would invalidate existing vectors.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 31afd52e997b.

Labels

Label justifications:

  • P2: This is a bounded repair to the optional LanceDB memory plugin's recall and embedding lifecycle behavior.
  • merge-risk: 🚨 compatibility: Existing operators can change embedding credentials or endpoints at runtime, while persisted vector identity must remain compatible across upgrades.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported loopback probe is supportive but no artifact was available for inspection.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame and repeated LanceDB lifecycle, credential-isolation, bounds, and refactor commits all point to this area owner. (role: feature owner and recent area contributor; confidence: high; commits: 95e17d6c993f, 72243fbef08f, 2eb424253ea5; files: extensions/memory-lancedb/index.ts, extensions/memory-lancedb/embeddings.ts)
  • yt2102: Authored the recent shared recall-cooldown repair in the same plugin, adjacent to the automatic and explicit recall paths changed here. (role: adjacent recall-path contributor; confidence: medium; commits: 9155d9000204; files: extensions/memory-lancedb/index.ts)
  • badgerbees: Prior LanceDB dimensions work is directly relevant to the startup-stable vector identity preserved by this head. (role: adjacent embedding-dimensions contributor; confidence: medium; commits: fedcffc4ae61; files: extensions/memory-lancedb/embeddings.ts, extensions/memory-lancedb/lancedb-store.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase or refresh the merge result and wait for exact-head required checks to complete.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

@steipete steipete self-assigned this Aug 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 18, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the ClawSweeper findings on the new head:

  • Preserved the persisted index identity: live config now rotates only embedding.apiKey and embedding.baseUrl; provider, model, and dimensions stay at their startup values until a planned re-embedding/rebuild and restart.
  • Added a native LanceDB regression showing that a persisted fixed-size table rejects a different vector dimension.
  • Updated the public Memory LanceDB guide for manual-store/recall bounds, live credential/endpoint rotation, and the semantic index-identity restart/rebuild rule.
  • Re-ran 163 focused tests, the 187-test plugin lane, MDX/link checks, the changed gate, git diff --check, and fresh autoreview; all passed.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 18, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for 2eb424253ea508ad462d263bf3d6cc63e3606692:

  • Resolved the index-identity review: live reload is limited to embedding.apiKey and embedding.baseUrl; provider, model, and dimensions remain startup-stable until a planned re-embedding/rebuild.
  • Focused Vitest: 163 passed.
  • Full memory-lancedb plugin lane: 187 passed.
  • MDX and docs link checks: passed, 0 broken links.
  • Changed gate and git diff --check: passed.
  • Real OpenAI SDK loopback rotation and native LanceDB fixed-size-table behavior were both exercised.
  • Fresh autoreview: no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/32103060044 — openclaw/ci-gate succeeded.
  • Latest ClawSweeper review has no findings. Its optional refresh rank-up is satisfied by green exact-head CI plus the native current-main prepare/test-merge gate; no branch rebase was done solely for behind-main drift.

@steipete
steipete merged commit b68d13a into main Aug 18, 2026
167 checks passed
@steipete
steipete deleted the steipete/bounded-memory-and-hot-reload-9aab48 branch August 18, 2026 05:55
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
…law#125567)

* fix(memory): bound LanceDB recall and reload embeddings

* fix(memory): preserve LanceDB index identity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: memory-lancedb Extension: memory-lancedb maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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