openclaw - ✅(Solved) Fix [Bug] memory_search tool throws 'Cannot read properties of undefined' in OpenClaw 4.14 (CLI works fine) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#67549Fetched 2026-04-17 08:30:11
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

In OpenClaw 4.14 (323493f), the memory_search agent tool call fails with error:

Cannot read properties of undefined (reading 'get')

However, the openclaw memory search CLI command works perfectly fine with the same query.

Error Message

In OpenClaw 4.14 (323493f), the memory_search agent tool call fails with error: 2. Immediately receive error: "error": "Cannot read properties of undefined (reading 'get')", "warning": "Memory search is unavailable due to an embedding/provider error."

Root Cause

In OpenClaw 4.14 (323493f), the memory_search agent tool call fails with error:

Cannot read properties of undefined (reading 'get')

However, the openclaw memory search CLI command works perfectly fine with the same query.

Fix Action

Fixed

PR fix notes

PR #67630: fix(memory): guard against stale qmdManagerCache singleton causing memory_search TypeError

Description (problem / solution / changelog)

Summary

Fixes #67549

memory_search agent tool throws TypeError: Cannot read properties of undefined (reading 'get') while openclaw memory search CLI works fine.

Root Cause

Same class of defect as #67525 (fixed in #67528).

In extensions/memory-core/src/memory/search-manager.ts, the module-level constant QMD_MANAGER_CACHE was destructured from getMemorySearchManagerCacheStore() at module initialization time:

const { qmdManagerCache: QMD_MANAGER_CACHE } = getMemorySearchManagerCacheStore();

getMemorySearchManagerCacheStore() uses resolveGlobalSingleton, which returns the existing globalThis value if the key exists — without validating the shape. If an older runtime version stored a different object shape at Symbol.for('openclaw.memorySearchManagerCache') (e.g. missing or renamed qmdManagerCache field), the destructuring yields undefined. Any subsequent QMD_MANAGER_CACHE.get(cacheKey) then throws:

TypeError: Cannot read properties of undefined (reading 'get')

The CLI path is unaffected because it uses a fresh process (no stale globalThis) and accesses the memory search manager through a separate import chain that doesn't go through the module-level constant.

Changes

extensions/memory-core/src/memory/search-manager.ts

  1. Shape validation in getMemorySearchManagerCacheStore: After resolveGlobalSingleton returns the store, validates that qmdManagerCache is a Map instance. If not, repairs it in-place, healing the singleton for all callers sharing the same globalThis slot.

  2. Lazy accessor replaces module-level constant: QMD_MANAGER_CACHE (bound at module init) replaced by getQmdManagerCache() function. Every call site now goes through the validated store path instead of capturing a potentially undefined reference at startup.

extensions/memory-core/src/memory/search-manager.test.ts

New describe('stale singleton cache guard') block with 3 tests:

  • getMemorySearchManager does not crash when qmdManagerCache is undefined
  • getMemorySearchManagerCacheStore repairs a stale singleton missing qmdManagerCache to an empty Map
  • closeAllMemorySearchManagers does not throw with stale qmdManagerCache

Relationship to #67525 / #67528

#67525#67549
Filesrc/plugins/interactive-state.tsextensions/memory-core/src/memory/search-manager.ts
Stale fieldcallbackDedupeqmdManagerCache
Crash method.clear().get()
Fix patternOptional chaininginstanceof guard + lazy accessor

Changed files

  • extensions/memory-core/src/memory/search-manager.test.ts (modified, +80/-1)
  • extensions/memory-core/src/memory/search-manager.ts (modified, +55/-13)

Code Example

Cannot read properties of undefined (reading 'get')

---

{
  "error": "Cannot read properties of undefined (reading 'get')",
  "warning": "Memory search is unavailable due to an embedding/provider error."
}
RAW_BUFFERClick to expand / collapse

Description

In OpenClaw 4.14 (323493f), the memory_search agent tool call fails with error:

Cannot read properties of undefined (reading 'get')

However, the openclaw memory search CLI command works perfectly fine with the same query.

Environment

  • Version: OpenClaw 2026.4.14 (323493f)
  • OS: Linux 6.12.48-1-MANJARO (x64)
  • Node: v24.14.0
  • Vector engine: ollama + nomic-embed-text
  • Memory backend: memory-builtin (SQLite + sqlite-vec)

Steps to Reproduce

  1. Invoke memory_search tool with any query
  2. Immediately receive error:
{
  "error": "Cannot read properties of undefined (reading 'get')",
  "warning": "Memory search is unavailable due to an embedding/provider error."
}

Additional Context

  • openclaw memory status shows: Vector: ready, FTS: ready, Indexed: 7 chunks, Dirty: no
  • openclaw memory search "xxx" CLI works correctly and returns results with similarity scores
  • This suggests the underlying memory/vector system is intact; the bug is in the agent tool invocation layer

Expected Behavior

memory_search() tool should work the same as the CLI command.

Possible Cause

Likely a regression in the agent runtime initialization of the memory_search tool where a provider/config object is not correctly injected, causing .get() to fail on undefined.

extent analysis

TL;DR

The memory_search agent tool call likely fails due to a regression in the agent runtime initialization, where a provider/config object is not correctly injected.

Guidance

  • Verify that the memory_search tool is correctly configured and initialized in the agent runtime, checking for any missing or incorrect provider/config object injections.
  • Compare the initialization code of the memory_search tool with the openclaw memory search CLI command to identify any differences.
  • Check the agent runtime logs for any errors or warnings related to the memory_search tool initialization.
  • Test the memory_search tool with a simple query to see if the issue is query-specific or a general initialization problem.

Example

No code snippet is provided as the issue lacks specific code details, but it is recommended to review the agent runtime initialization code for the memory_search tool.

Notes

The issue seems to be specific to the agent tool invocation layer, and the underlying memory/vector system appears to be intact. The openclaw memory search CLI command working correctly suggests that the issue is not with the memory backend or vector engine.

Recommendation

Apply a workaround by manually injecting the required provider/config object into the memory_search tool initialization code, if possible, until the regression is fixed in a future version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug] memory_search tool throws 'Cannot read properties of undefined' in OpenClaw 4.14 (CLI works fine) [1 pull requests, 1 participants]