← Back to PRs

#11179: fix(memory): replace confusing "No API key" errors in memory tools fallback path

by liuxiaopai-ai open 2026-02-07 14:11 View on GitHub →
stale
## 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