openclaw - ✅(Solved) Fix Bug: openclaw memory search times out when eager context-window warmup runs for the memory command [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#73123Fetched 2026-04-28 06:27:18
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
closed ×1cross-referenced ×1

openclaw memory search can time out during Gemini query embedding generation even though:

  • the Gemini API works directly;
  • OpenClaw's Gemini embedding provider works when invoked directly;
  • MemoryIndexManager.search() works when invoked directly;
  • runMemorySearch() works when invoked directly;
  • runCli(argv) works when called with an explicit argv array.

The failure appears only when process.argv globally looks like a real OpenClaw memory command. In that case, context-DxSDN9vA.js eagerly starts context-window cache warmup at module import time:

if (shouldEagerWarmContextWindowCache()) ensureContextWindowCacheLoaded();

Since memory is not in SKIP_EAGER_WARMUP_PRIMARY_COMMANDS, the warmup runs concurrently with the memory search command. Adding "memory" to SKIP_EAGER_WARMUP_PRIMARY_COMMANDS fixes the issue locally.

Root Cause

This points to the eager context-window warmup, because status is already in SKIP_EAGER_WARMUP_PRIMARY_COMMANDS, while memory is not.

Fix Action

Fix / Workaround

Observed result before the patch:

Local workaround / proposed fix

Patch:

PR fix notes

PR #73139: fix(cli): skip memory eager context warmup

Description (problem / solution / changelog)

Summary

  • Add memory to the CLI commands that skip eager context-window cache warmup.
  • Cover both the command-classification helper and import-time side effect so openclaw memory search does not start unrelated model metadata discovery.
  • Add an unreleased changelog entry for #73123.

Root Cause

src/agents/context.ts eagerly warms context-window metadata on import for real OpenClaw CLI invocations unless the primary command is in SKIP_EAGER_WARMUP_PRIMARY_COMMANDS. memory was missing from that skip list, so openclaw memory search could start context-window/model metadata discovery concurrently with the memory embedding search path.

Linked Issue

Fixes #73123.

Why This Is Safe

openclaw memory commands do not need context-window metadata during CLI startup; memory search manages its own memory manager, index, and embedding provider lifecycle. The change matches existing skipped read-only or maintenance commands such as logs, status, and sessions, and only disables import-time warmup for the memory primary command.

Security And Runtime Controls

No auth, secret resolution, proxy behavior, embedding provider policy, prompt text, or runtime security control changes. Memory command secret resolution and memory manager behavior remain unchanged; this only prevents unrelated background context-window warmup from starting on memory CLI imports.

Tests

  • git diff --check origin/main...HEAD
  • pnpm test src/agents/context.lookup.test.ts src/agents/context.eager-warmup.test.ts
  • pnpm check:changed

Out Of Scope

  • Changes to memory embedding provider timeout behavior.
  • Changes to context-window warmup for chat or other model-running startup commands.
  • Broader refactors of CLI command registration or memory runtime lifecycle.

Contributor Notes

  • AI-assisted: yes.
  • Testing: focused tests plus changed gate passed.

Made with Cursor

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/agents/context.eager-warmup.test.ts (modified, +1/-0)
  • src/agents/context.lookup.test.ts (modified, +3/-0)
  • src/agents/context.ts (modified, +1/-0)

Code Example

if (shouldEagerWarmContextWindowCache()) ensureContextWindowCacheLoaded();

---

OPENCLAW_DEBUG_MEMORY_EMBEDDINGS=1 \
openclaw memory search \
  --query 'openclaw memory search diagnostic' \
  --max-results 3 \
  --json \
  --agent main

---

memory embeddings: gemini client {"rawBaseUrl":"https://generativelanguage.googleapis.com/v1beta", ...}
Memory search failed: memory embeddings query timed out after 60s

---

Memory search failed: fetch failed | other side closed

---

import { createGeminiEmbeddingProvider } from '/usr/lib/node_modules/openclaw/dist/extensions/google/embedding-provider.js';

---

ok=true, model=gemini-embedding-001, valuesLen=3072

---

import { runCli } from '/usr/lib/node_modules/openclaw/dist/run-main-C0UBGHN3.js';

await runCli([
  process.execPath,
  '/usr/lib/node_modules/openclaw/openclaw.mjs',
  'memory',
  'search',
  '--query',
  'openclaw memory search diagnostic',
  '--max-results',
  '3',
  '--json',
  '--agent',
  'main'
]);

---

import { runCli } from '/usr/lib/node_modules/openclaw/dist/run-main-C0UBGHN3.js';

const argv = [
  process.execPath,
  '/usr/lib/node_modules/openclaw/openclaw.mjs',
  'memory',
  'search',
  '--query',
  'openclaw memory search diagnostic',
  '--max-results',
  '3',
  '--json',
  '--agent',
  'main'
];

process.argv = argv;
await runCli(argv);

---

Memory search failed: memory embeddings query timed out after 60s

---

import { runCli } from '/usr/lib/node_modules/openclaw/dist/run-main-C0UBGHN3.js';

const realArgv = [
  process.execPath,
  '/usr/lib/node_modules/openclaw/openclaw.mjs',
  'memory',
  'search',
  '--query',
  'openclaw memory search diagnostic',
  '--max-results',
  '3',
  '--json',
  '--agent',
  'main'
];

process.argv = [process.execPath, '/usr/lib/node_modules/openclaw/openclaw.mjs', 'status'];
await runCli(realArgv);

---

exit=0, returned 3 results

---

--- a/dist/context-DxSDN9vA.js
+++ b/dist/context-DxSDN9vA.js
@@ -113,6 +113,7 @@
   "health",
   "hooks",
   "logs",
+  "memory",
   "models",
   "pairing",
   "plugins",

---

actual_cli_after_patch_exit=0
duration_s=16
stdout: 3 JSON results

---

exit=0
duration_s=8
files=120
chunks=447
dirty=false
provider=gemini
model=gemini-embedding-001
fts.enabled=true
fts.available=true
vector.enabled=false

---

if (shouldEagerWarmContextWindowCache()) ensureContextWindowCacheLoaded();
RAW_BUFFERClick to expand / collapse

Bug: openclaw memory search times out when eager context-window warmup runs for the memory command

Summary

openclaw memory search can time out during Gemini query embedding generation even though:

  • the Gemini API works directly;
  • OpenClaw's Gemini embedding provider works when invoked directly;
  • MemoryIndexManager.search() works when invoked directly;
  • runMemorySearch() works when invoked directly;
  • runCli(argv) works when called with an explicit argv array.

The failure appears only when process.argv globally looks like a real OpenClaw memory command. In that case, context-DxSDN9vA.js eagerly starts context-window cache warmup at module import time:

if (shouldEagerWarmContextWindowCache()) ensureContextWindowCacheLoaded();

Since memory is not in SKIP_EAGER_WARMUP_PRIMARY_COMMANDS, the warmup runs concurrently with the memory search command. Adding "memory" to SKIP_EAGER_WARMUP_PRIMARY_COMMANDS fixes the issue locally.

Environment

  • OpenClaw version: OpenClaw 2026.4.25 (aa36ee6)
  • Node.js version: v22.22.2
  • OS: Linux x64
  • Shell: bash
  • Install path: /usr/lib/node_modules/openclaw
  • CLI wrapper: /usr/local/bin/openclaw -> /usr/lib/node_modules/openclaw/openclaw.mjs
  • Memory backend: builtin SQLite/FTS
  • Memory provider: gemini
  • Memory model: gemini-embedding-001
  • Memory vector store: disabled via store.vector.enabled=false
  • Memory index status after fix: 120 files, 447 chunks, dirty=false

Actual behavior

Running the real CLI wrapper hangs until the embedding query timeout:

OPENCLAW_DEBUG_MEMORY_EMBEDDINGS=1 \
openclaw memory search \
  --query 'openclaw memory search diagnostic' \
  --max-results 3 \
  --json \
  --agent main

Observed result before the patch:

memory embeddings: gemini client {"rawBaseUrl":"https://generativelanguage.googleapis.com/v1beta", ...}
Memory search failed: memory embeddings query timed out after 60s

Other runs of the same command also failed with:

Memory search failed: fetch failed | other side closed

Expected behavior

openclaw memory search should complete normally, just like the direct runtime invocation does.

Key isolation tests

1. Gemini API itself works

Direct Gemini embedding request with the same resolved API key returned HTTP 200 and a 3072-dimensional vector.

2. OpenClaw Gemini embedding provider works directly

Importing and calling the installed provider directly succeeded:

import { createGeminiEmbeddingProvider } from '/usr/lib/node_modules/openclaw/dist/extensions/google/embedding-provider.js';

Result:

ok=true, model=gemini-embedding-001, valuesLen=3072

3. Memory manager works directly

Direct MemoryIndexManager.get(...).search(...) returned 3 results in about 10s.

4. runMemorySearch() works directly

Direct import from cli.runtime-Xk5Be4LD.js returned 3 JSON results in about 10s.

5. runCli(argv) works if process.argv is not set to the real memory command

This succeeds:

import { runCli } from '/usr/lib/node_modules/openclaw/dist/run-main-C0UBGHN3.js';

await runCli([
  process.execPath,
  '/usr/lib/node_modules/openclaw/openclaw.mjs',
  'memory',
  'search',
  '--query',
  'openclaw memory search diagnostic',
  '--max-results',
  '3',
  '--json',
  '--agent',
  'main'
]);

6. The same runCli(argv) fails when process.argv globally matches the memory command

This reproduces the timeout:

import { runCli } from '/usr/lib/node_modules/openclaw/dist/run-main-C0UBGHN3.js';

const argv = [
  process.execPath,
  '/usr/lib/node_modules/openclaw/openclaw.mjs',
  'memory',
  'search',
  '--query',
  'openclaw memory search diagnostic',
  '--max-results',
  '3',
  '--json',
  '--agent',
  'main'
];

process.argv = argv;
await runCli(argv);

Observed result:

Memory search failed: memory embeddings query timed out after 60s

7. Changing only global process.argv to a skipped command makes the same memory search succeed

This succeeds:

import { runCli } from '/usr/lib/node_modules/openclaw/dist/run-main-C0UBGHN3.js';

const realArgv = [
  process.execPath,
  '/usr/lib/node_modules/openclaw/openclaw.mjs',
  'memory',
  'search',
  '--query',
  'openclaw memory search diagnostic',
  '--max-results',
  '3',
  '--json',
  '--agent',
  'main'
];

process.argv = [process.execPath, '/usr/lib/node_modules/openclaw/openclaw.mjs', 'status'];
await runCli(realArgv);

Result:

exit=0, returned 3 results

This points to the eager context-window warmup, because status is already in SKIP_EAGER_WARMUP_PRIMARY_COMMANDS, while memory is not.

Local workaround / proposed fix

Patch:

--- a/dist/context-DxSDN9vA.js
+++ b/dist/context-DxSDN9vA.js
@@ -113,6 +113,7 @@
   "health",
   "hooks",
   "logs",
+  "memory",
   "models",
   "pairing",
   "plugins",

After adding "memory" to SKIP_EAGER_WARMUP_PRIMARY_COMMANDS, the real CLI wrapper works:

actual_cli_after_patch_exit=0
duration_s=16
stdout: 3 JSON results

openclaw memory status --json --agent main also works:

exit=0
duration_s=8
files=120
chunks=447
dirty=false
provider=gemini
model=gemini-embedding-001
fts.enabled=true
fts.available=true
vector.enabled=false

Root cause hypothesis

src/agents/context.ts or the compiled equivalent starts async context-window warmup at import time whenever process.argv looks like an OpenClaw CLI command and the primary command is not skipped:

if (shouldEagerWarmContextWindowCache()) ensureContextWindowCacheLoaded();

For the memory command, this warmup is unnecessary and can interfere with memory embedding fetches. The command-specific memory runtime already manages its own provider and index lifecycle.

Suggested upstream fix

Add memory to SKIP_EAGER_WARMUP_PRIMARY_COMMANDS, or otherwise prevent eager context-window warmup from running for memory/index/search/status commands.

Related issues / prior fixes checked

  • #56901: Gemini memory indexing/search can fail with fetch failed while direct Gemini calls work.
  • #52162 / #71506: remote memory embeddings proxy/guarded-fetch fix. This install already includes the v2026.4.25 fix, so this report appears to be a separate issue.
  • #26792: FTS-only memory search/index behavior; related as a fallback path but not the cause here.

Impact

High for users using remote embeddings with openclaw memory search: the CLI can consistently time out even though the provider and memory runtime work. The workaround is a local dist patch, but that will be lost on package updates.

extent analysis

TL;DR

Adding "memory" to SKIP_EAGER_WARMUP_PRIMARY_COMMANDS is the most likely fix to prevent the eager context-window warmup from interfering with the openclaw memory search command.

Guidance

  1. Verify the issue: Confirm that the openclaw memory search command times out due to the eager context-window warmup by checking the debug logs with OPENCLAW_DEBUG_MEMORY_EMBEDDINGS=1.
  2. Apply the local workaround: Patch the context-DxSDN9vA.js file by adding "memory" to SKIP_EAGER_WARMUP_PRIMARY_COMMANDS to prevent the eager warmup for the memory command.
  3. Test the fix: Run the openclaw memory search command again to verify that it completes normally without timing out.
  4. Check for related issues: Review the related issues mentioned (#56901, #52162, #71506, #26792) to ensure that the fix does not introduce any regressions.

Example

No code snippet is provided as the issue is resolved by modifying the SKIP_EAGER_WARMUP_PRIMARY_COMMANDS array.

Notes

The fix may need to be reapplied after package updates, and the upstream fix should be prioritized to prevent similar issues in the future.

Recommendation

Apply the workaround by adding "memory" to SKIP_EAGER_WARMUP_PRIMARY_COMMANDS to prevent the eager context-window warmup from interfering with the openclaw memory search command. This fix is necessary to ensure that the command completes normally without timing out.

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…

FAQ

Expected behavior

openclaw memory search should complete normally, just like the direct runtime invocation does.

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: openclaw memory search times out when eager context-window warmup runs for the memory command [1 pull requests, 1 participants]