Bug Report: Memory Index Fails for Main Agent
Issue Summary
OpenClaw main agent memory indexing consistently fails with fetch failed error when attempting to generate embeddings via Gemini API. Other agents appear to "succeed" only because they have no memory files to index.
Environment
- OpenClaw Version: 2026.3.28 (latest as of 2026-03-29)
- Previous Version: 2026.3.24 (issue persists across versions)
- Operating System: Linux 6.4.0-150600.23.87-default (x64)
- Node.js Version: v24.14.1
- Shell: bash
- Workspace:
~/.openclaw/workspace
- Memory Directory:
~/.openclaw/workspace/memory/
Error Details
Error Message
```
Memory index failed (main): fetch failed
```
Full Output from `openclaw memory status`
```
Memory Search (main)
Provider: gemini (requested: gemini)
Model: gemini-embedding-2-preview
Sources: memory
Indexed: 0/11 files · 0 chunks
Dirty: yes
Store: ~/.openclaw/memory/main.sqlite
Workspace: ~/.openclaw/workspace
By source:
memory · 0/11 files · 0 chunks
Vector: ready
Vector path: ~/.nvm/versions/node/v24.14.1/lib/node_modules/openclaw/node_modules/sqlite-vec-linux-x64/vec0.so
FTS: ready
Embedding cache: enabled (0 entries)
Batch: disabled (failures 0/2)
```
Reproduction Steps
- Ensure memory files exist in `~/.openclaw/workspace/memory/` (11 files)
- Run: `openclaw memory index --force`
- Observe error: `Memory index failed (main): fetch failed`
- Note that other agents (product-designer, system-architect, etc.) report "success" but have 0/0 files indexed
Verification Tests
✅ Gemini API Works Correctly
```bash
Test single embedding request
curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-embedding-2-preview:embedContent?key=<REDACTED_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"content":{"parts":[{"text":"test"}]}}' | jq '.embedding.values | length'
Result: 3072 (successful)
```
✅ File Permissions Are Correct
```bash
ls -la ~/.openclaw/workspace/memory/*.md
All files have 644 permissions (readable)
```
✅ SQLite Database Is Functional
```bash
sqlite3 ~/.openclaw/memory/main.sqlite "PRAGMA table_info(files);"
Returns: path, source, hash, mtime, size (correct schema)
```
✅ Vector Extension Is Loaded
```
Vector: ready
Vector path: ~/.nvm/versions/node/v24.14.1/lib/node_modules/openclaw/node_modules/sqlite-vec-linux-x64/vec0.so
```
❌ Embedding Generation Fails
The `fetch failed` error occurs when OpenClaw's internal code attempts to generate embeddings, despite direct API calls working fine.
Attempted Solutions (All Failed)
| Solution |
Result |
| Update OpenClaw 2026.3.24 → 2026.3.28 |
❌ No change - error persists |
| Switch embedding model: gemini-embedding-2-preview → gemini-embedding-001 |
❌ No change - error persists |
| Reset SQLite database (delete and recreate) |
❌ No change - error persists |
| Fix file permissions (600 → 644) |
❌ No change - error persists |
| Verify API key and configuration |
❌ API is not the issue (curl works) |
| Enable fallback to FTS |
❌ No change - error persists (FTS also not indexed) |
| Disable and re-enable memorySearch |
❌ No change - error persists |
Root Cause Analysis
Key Finding
The issue is in OpenClaw's internal embedding generation code, not in:
- The Gemini API (proven functional)
- File system (permissions, disk space all normal)
- Database (SQLite schema correct)
- Vector extension (sqlite-vec loaded correctly)
Possible Causes
- Batch processing logic - May have a bug specific to how main agent processes memory files
- File reading/parsing - May fail specifically for main agent's memory file format
- Configuration difference - Main agent may have different internal config than other agents
- Network request implementation - OpenClaw's fetch wrapper may have issues specific to main agent
- API request formatting - May generate malformed requests that fail despite direct API calls working
Why Other Agents "Succeed"
Other agents (product-designer, system-architect, frontend-dev, backend-dev, qa-engineer, devops-engineer) report `Memory index updated` but have:
- 0/0 files indexed - They have no memory files to process
- No actual embedding generation occurs
- This is a false positive - they don't fail because they don't try
Impact
Current Workaround
```json
{
"memorySearch": {
"enabled": false
}
}
```
This prevents the error but also:
- ❌ Disables vector search functionality
- ❌ Loses semantic memory search
- ❌ Reduces OpenClaw's effectiveness
Manual Workaround Created
A simple grep-based search script has been created:
```bash
~/.openclaw/workspace/scripts/memory-search.sh "keyword"
```
This provides basic keyword search but lacks:
- Semantic similarity
- Vector-based ranking
- Contextual understanding
Additional Information
Memory Files Requiring Indexing (11 files)
- `MEMORY.md` (1.2K - long-term memory)
- `2026-03-21-1759.md` (151 lines)
- `2026-03-24-0826.md` (5 lines)
- `2026-03-24-400-error-code-400-message-ple.md` (91 lines)
- `2026-03-26-0330.md` (140 lines)
- `2026-03-26-new-session.md` (17 lines)
- `2026-03-26-prd-generation.md` (245 lines)
- `2026-03-26-telegram-auth-fix.md` (115 lines)
- `2026-03-27-model-test.md` (37 lines)
- `2026-03-29-session-startup.md` (64 lines)
- `test-index.md` (11 lines)
Configuration
```json
{
"memorySearch": {
"enabled": true,
"provider": "gemini",
"model": "gemini-embedding-2-preview",
"fallback": "fts",
"remote": {
"apiKey": "",
"batch": {
"enabled": false
}
}
}
}
```
Expected Behavior
Memory files should be indexed successfully with embeddings generated and stored in SQLite database, enabling semantic search via `memory_search` function.
Actual Behavior
OpenClaw fails with `fetch failed` error when attempting to generate embeddings for memory files. No embeddings are stored, and vector search is unavailable.
Priority
Medium - Workaround exists (manual search script) but core functionality (semantic memory search) is lost.
Labels
bug, extensions: memory-core
Additional Notes
- Full diagnostic report available at `/tmp/memory-index-debug-report.md`
- Manual search script working at `~/.openclaw/workspace/scripts/memory-search.sh`
- Issue affects only main agent - other agents with 0 memory files appear to succeed
- This suggests a code path specific to processing multiple memory files
References
Bug Report: Memory Index Fails for Main Agent
Issue Summary
OpenClaw main agent memory indexing consistently fails with
fetch failederror when attempting to generate embeddings via Gemini API. Other agents appear to "succeed" only because they have no memory files to index.Environment
~/.openclaw/workspace~/.openclaw/workspace/memory/Error Details
Error Message
```
Memory index failed (main): fetch failed
```
Full Output from `openclaw memory status`
```
Memory Search (main)
Provider: gemini (requested: gemini)
Model: gemini-embedding-2-preview
Sources: memory
Indexed: 0/11 files · 0 chunks
Dirty: yes
Store: ~/.openclaw/memory/main.sqlite
Workspace: ~/.openclaw/workspace
By source:
memory · 0/11 files · 0 chunks
Vector: ready
Vector path: ~/.nvm/versions/node/v24.14.1/lib/node_modules/openclaw/node_modules/sqlite-vec-linux-x64/vec0.so
FTS: ready
Embedding cache: enabled (0 entries)
Batch: disabled (failures 0/2)
```
Reproduction Steps
Verification Tests
✅ Gemini API Works Correctly
```bash
Test single embedding request
curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-embedding-2-preview:embedContent?key=<REDACTED_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"content":{"parts":[{"text":"test"}]}}' | jq '.embedding.values | length'
Result: 3072 (successful)
```
✅ File Permissions Are Correct
```bash
ls -la ~/.openclaw/workspace/memory/*.md
All files have 644 permissions (readable)
```
✅ SQLite Database Is Functional
```bash
sqlite3 ~/.openclaw/memory/main.sqlite "PRAGMA table_info(files);"
Returns: path, source, hash, mtime, size (correct schema)
```
✅ Vector Extension Is Loaded
```
Vector: ready
Vector path: ~/.nvm/versions/node/v24.14.1/lib/node_modules/openclaw/node_modules/sqlite-vec-linux-x64/vec0.so
```
❌ Embedding Generation Fails
The `fetch failed` error occurs when OpenClaw's internal code attempts to generate embeddings, despite direct API calls working fine.
Attempted Solutions (All Failed)
Root Cause Analysis
Key Finding
The issue is in OpenClaw's internal embedding generation code, not in:
Possible Causes
Why Other Agents "Succeed"
Other agents (product-designer, system-architect, frontend-dev, backend-dev, qa-engineer, devops-engineer) report `Memory index updated` but have:
Impact
Current Workaround
```json
{
"memorySearch": {
"enabled": false
}
}
```
This prevents the error but also:
Manual Workaround Created
A simple grep-based search script has been created:
```bash
~/.openclaw/workspace/scripts/memory-search.sh "keyword"
```
This provides basic keyword search but lacks:
Additional Information
Memory Files Requiring Indexing (11 files)
Configuration
```json
{
"memorySearch": {
"enabled": true,
"provider": "gemini",
"model": "gemini-embedding-2-preview",
"fallback": "fts",
"remote": {
"apiKey": "",
"batch": {
"enabled": false
}
}
}
}
```
Expected Behavior
Memory files should be indexed successfully with embeddings generated and stored in SQLite database, enabling semantic search via `memory_search` function.
Actual Behavior
OpenClaw fails with `fetch failed` error when attempting to generate embeddings for memory files. No embeddings are stored, and vector search is unavailable.
Priority
Medium - Workaround exists (manual search script) but core functionality (semantic memory search) is lost.
Labels
bug,extensions: memory-coreAdditional Notes
References