Bug Summary
When the gateway reloads or openclaw memory index --force is executed, the meta table in the SQLite memory databases is not written. This causes the index identity check to fail on subsequent memory searches, resulting in:
Index identity: index metadata is missing (if meta was completely missing)
Index identity: index provider settings changed (if meta was present but providerKey mismatch)
Vector search: paused until memory is rebuilt
Reproduction Steps
- Ensure memory search is working (e.g.,
memory_search tool returns results)
- Trigger a gateway reload OR run
openclaw memory index --force --agent <agent>
- After the reload/reindex completes, run
openclaw memory status --agent <agent>
- Observe the index identity warning
Root Cause Analysis
The meta write happens in runSafeReindex() at manager-dZw31DAG2.js around line 2260-2280:
const meta = {
model: this.provider?.model ?? "fts-only",
provider: this.provider?.id ?? "none",
providerKey: this.providerKey,
// ...
};
this.writeMeta(meta);
The issue is that this.provider and this.providerKey may not be initialized when writeMeta is called during the --force reindex flow. The provider initialization is lazy — ensureProviderInitialized() is called elsewhere (e.g., before sync()) but not before the safe reindex path writes meta.
When the provider is not initialized:
this.provider?.model resolves to undefined (not the default model)
this.providerKey is undefined or computed incorrectly
- The meta table ends up with an empty model or wrong providerKey
Additionally, after the config change is applied and the gateway hot-reloads, the memory managers are recreated and the old meta rows may be lost during the atomic reindex swap (the build() function in runSafeReindex creates a fresh temp DB, but the provider isn't initialized before writeMeta runs).
Expected Behavior
openclaw memory index --force should always write a correct meta row with the resolved model, provider, and providerKey, matching the actual embeddings used to index the chunks.
Actual Behavior
meta is either missing or contains incorrect values (empty model, wrong providerKey), causing the index identity check to fail on the next status check or search.
Workaround
Manually insert the correct meta row into ~/.openclaw/memory/<agent>.sqlite:
import sqlite3, json
meta = {
"model": "text-embedding-3-small",
"provider": "openai",
"providerKey": "<computed_provider_key>",
"sources": ["memory"],
"scopeHash": "<computed_scope_hash>",
"chunkTokens": 400,
"chunkOverlap": 80,
"ftsTokenizer": "unicode61",
"vectorDims": 1536
}
# INSERT INTO meta (key, value) VALUES ('memory_index_meta_v1', json.dumps(meta))
Suggested Fix
Ensure ensureProviderInitialized() is called before writeMeta() in the runSafeReindex/build() path. The provider must be fully initialized so that:
this.provider.model is resolved to the actual model (e.g., text-embedding-3-small)
this.providerKey is computed from providerRuntime.cacheKeyData (for OpenAI: includes provider, baseUrl, model, headers)
Specifically, in manager-dZw31DAG2.js around line 2260, add await this.ensureProviderInitialized() before building the meta object.
Environment
- OpenClaw version: 2026.6.1
- OS: Linux 6.8.0-124-generic
- Node: v24.16.0
- Memory backend: builtin (sqlite-vec)
- Embedding provider: openai / text-embedding-3-small
- Affected agents: main, engineer, writer (all agents with memory search enabled)
Related Code Locations
manager-dZw31DAG2.js:2260-2280 — writeMeta(meta) in runSafeReindex
manager-dZw31DAG2.js:1130-1160 — resolveCurrentIndexIdentityState (reads meta for comparison)
manager-dZw31DAG2.js:2520-2528 — computeProviderKey() (providerKey computation)
memory-embedding-adapter-ebyy2fpA.js — OpenAI adapter, defines cacheKeyData used for providerKey
Bug Summary
When the gateway reloads or
openclaw memory index --forceis executed, themetatable in the SQLite memory databases is not written. This causes the index identity check to fail on subsequent memory searches, resulting in:Index identity: index metadata is missing(if meta was completely missing)Index identity: index provider settings changed(if meta was present but providerKey mismatch)Vector search: paused until memory is rebuiltReproduction Steps
memory_searchtool returns results)openclaw memory index --force --agent <agent>openclaw memory status --agent <agent>Root Cause Analysis
The
metawrite happens inrunSafeReindex()atmanager-dZw31DAG2.jsaround line 2260-2280:The issue is that
this.providerandthis.providerKeymay not be initialized whenwriteMetais called during the--forcereindex flow. The provider initialization is lazy —ensureProviderInitialized()is called elsewhere (e.g., beforesync()) but not before the safe reindex path writes meta.When the provider is not initialized:
this.provider?.modelresolves toundefined(not the default model)this.providerKeyis undefined or computed incorrectlyAdditionally, after the config change is applied and the gateway hot-reloads, the memory managers are recreated and the old
metarows may be lost during the atomic reindex swap (thebuild()function inrunSafeReindexcreates a fresh temp DB, but the provider isn't initialized beforewriteMetaruns).Expected Behavior
openclaw memory index --forceshould always write a correctmetarow with the resolved model, provider, and providerKey, matching the actual embeddings used to index the chunks.Actual Behavior
metais either missing or contains incorrect values (empty model, wrong providerKey), causing the index identity check to fail on the next status check or search.Workaround
Manually insert the correct
metarow into~/.openclaw/memory/<agent>.sqlite:Suggested Fix
Ensure
ensureProviderInitialized()is called beforewriteMeta()in therunSafeReindex/build()path. The provider must be fully initialized so that:this.provider.modelis resolved to the actual model (e.g.,text-embedding-3-small)this.providerKeyis computed fromproviderRuntime.cacheKeyData(for OpenAI: includesprovider,baseUrl,model,headers)Specifically, in
manager-dZw31DAG2.jsaround line 2260, addawait this.ensureProviderInitialized()before building the meta object.Environment
Related Code Locations
manager-dZw31DAG2.js:2260-2280—writeMeta(meta)inrunSafeReindexmanager-dZw31DAG2.js:1130-1160—resolveCurrentIndexIdentityState(reads meta for comparison)manager-dZw31DAG2.js:2520-2528—computeProviderKey()(providerKey computation)memory-embedding-adapter-ebyy2fpA.js— OpenAI adapter, definescacheKeyDataused for providerKey