#11179: fix(memory): replace confusing "No API key" errors in memory tools fallback path
stale
Cluster:
Memory Management Enhancements
## Summary
When `memory.backend = "qmd"` with local embeddings configured, the `memory_search` and `memory_get` tools fail with confusing cascading "No API key found for provider" errors — even though:
1. The user explicitly configured local/QMD embeddings (no remote API keys needed)
2. The CLI (`openclaw memory index`) works perfectly with the same local setup
3. The error messages reference OpenAI/Google/Voyage providers the user never intended to use
## Root Cause
The fallback chain in `search-manager.ts`:
1. QMD backend fails (e.g., `qmd` command unavailable, timeout, etc.)
2. Falls back to builtin `MemoryIndexManager.get()`
3. `MemoryIndexManager` calls `createEmbeddingProvider()` with the resolved config
4. If `memorySearch.provider` is not explicitly set, it defaults to `"auto"`
5. Auto mode iterates openai → gemini → voyage, each throwing "No API key found for provider …"
6. All three errors are concatenated and surfaced to the user
The user sees three auth errors for providers they never configured, with no guidance on what to actually do.
## Fix
Introduce `tryBuiltinIndex()` wrapper that:
- **Detects** cascading "No API key" errors from the auto provider strategy
- **Replaces** them with a single actionable message explaining the available provider options
- **Routes** both the QMD fallback path and the direct builtin path through the same improved error handling
### Before
```
No API key found for provider "openai". You are authenticated with …
No API key found for provider "google". Auth store: …
No API key found for provider "voyage". …
```
### After
```
Memory search requires an embedding provider but none is configured.
Set agents.defaults.memorySearch.provider to "local" (requires node-llama-cpp),
"openai", "gemini", or "voyage" with the corresponding API key.
If you use memory.backend = "qmd", also ensure the qmd command is available.
```
## Files Changed
- `src/memory/search-manager.ts` — 1 file, +56 −10 lines
## Testing
The change is backward-compatible:
- Users with working remote providers see no difference
- Users with working local/QMD setups see no difference
- Users hitting the auth error now get an actionable message instead of a confusing cascade
Closes #8131
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR refactors `src/memory/search-manager.ts` to route both the direct builtin memory-index path and the QMD fallback path through a new `tryBuiltinIndex()` wrapper. The wrapper detects the common `provider="auto"` cascade of "No API key found for provider …" errors and replaces it with a single, more actionable configuration message explaining how to select an embedding provider (local/openai/gemini/voyage) and, when using QMD, ensuring the `qmd` command is available.
Overall this improves user-facing errors when builtin memory search cannot create an embedding provider, especially when QMD is configured but unavailable.
<h3>Confidence Score: 4/5</h3>
- This PR is mostly safe to merge, but one logic issue can hide the new actionable error in the QMD fallback flow.
- Changes are localized to memory manager selection and primarily improve error messaging. However, the QMD→builtin fallback currently drops `tryBuiltinIndex()`’s error message, so in real failure scenarios users may still see the original QMD failure instead of the intended actionable provider guidance.
- src/memory/search-manager.ts
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#9149: Fix: Allow QMD backend to work without OpenAI auth
by vishaltandale00 · 2026-02-04
86.6%
#21471: fix: check QMD backend before memory search config
by lbo728 · 2026-02-20
82.0%
#20125: fix(doctor): skip memorySearch provider check when using QMD backend
by brandonwise · 2026-02-18
82.0%
#17660: fix: skip embedding provider check in doctor when QMD backend is co...
by echoVic · 2026-02-16
81.4%
#9624: fix(memory): resolve QMD search returning empty results [AI-assisted]
by kowshik24 · 2026-02-05
81.1%
#19920: fix(memory): populate FTS index in FTS-only mode so search returns ...
by forketyfork · 2026-02-18
80.8%
#11364: fix(memory/qmd): prevent cascading failure when query fails or retu...
by blazerui · 2026-02-07
79.5%
#13045: feat(doctor): add memory search embeddings provider health check
by asklee-klawd · 2026-02-10
79.3%
#10801: fix: eagerly initialize QMD memory backend on gateway startup
by 1kuna · 2026-02-07
77.5%
#22937: fix: remove legacy unsuffixed QMD collections on upgrade
by sud0n1m-ziggy · 2026-02-21
77.1%