Skip to content

[P0] memory_search cassé — index metadata is missing depuis v2026.6.1, reproduit sur v2026.6.5 #91778

Closed as not planned

Description

@1attila2

🐛 Bug Report — OpenClaw memory_search index metadata is missing

Date : 2026-06-09
Rédactrice : Mami-Nora (via Nóra CEO)
Sévérité : P0 — Tous les agents aveugles (memory_search vectoriel HS depuis le 2 juin)
Versions affectées : v2026.6.1, v2026.6.5


Symptôme

memory_search (API runtime) → "index metadata is missing"
Vector search: paused until memory is rebuilt

Les agents ne peuvent pas faire de recherche sémantique. Seul le full-text search (FTS) fonctionne.


Configuration

// agents.defaults.memorySearch
{
  "provider": "openai-compatible",
  "model": "openai/text-embedding-3-large"
}

// models.providers["openai-compatible"]
{
  "baseUrl": "https://openrouter.ai/api/v1",
  "apiKey": "${OPENROUTER_API_KEY}",
  "models": [
    {
      "id": "openai/text-embedding-3-large",
      "contextWindow": 8191
    }
  ]
}

La clé OpenRouter est valide (200 OK sur les appels d'embedding).


Reproduction (100% fiable)

Étape 1 — Rebuild CLI

openclaw memory status --index --agent nora
openclaw memory index --agent nora --force

Résultat :

Memory index complete.
Provider: openai-compatible (requested: openai-compatible)
Dirty: no
Embeddings: ready
Vector dims: 3072
Memory index updated (nora).

Étape 2 — Vérification CLI

openclaw memory status

Résultat :

Memory Search (nora)
Provider: openai-compatible (requested: openai-compatible)
Model: openai/text-embedding-3-large
Indexed: 7/7 files · 11 chunks
Dirty: yes
Index identity: index metadata is missing
Vector search: paused until memory is rebuilt

Étape 3 — API runtime

L'appel memory_search depuis une session d'agent retourne la même erreur index metadata is missing.


Ce qui a été tenté (6 tentatives, 0 succès)

# Action Résultat
1 memory index --force ❌
2 Wipe 29 .sqlite + restart + rebuild ❌
3 Provider openrouter → openai-compatible ❌
4 Ajout bloc models.providers["openai-compatible"] ❌
5 Retrait api: "openai-completions" du bloc openai-compatible ❌
6 Upgrade v2026.6.1 → v2026.6.5 ❌

Tentatives additionnelles : --force, --index, wipe partiel, rebuild sans restart, rebuild avec restart.


Hypothèse

memory status (sans --index) corrompt ou invalide le metadata de l'index SQLite. Le Gateway utilise le même chemin de validation pour les appels API memory_search → l'index est systématiquement invalidé.

Le CLI memory status --index répare l'index, mais le prochain memory status (ou appel API) le recasse.


Impact

  • 24 agents ne peuvent pas utiliser memory_search vectoriel
  • Seul le FTS (full-text search) fonctionne
  • Perte de contexte : les agents ne peuvent pas chercher dans les transcriptions de sessions passées
  • Depuis le 2 juin 2026

Fichiers concernés

  • openclaw.json : agents.defaults.memorySearch + models.providers["openai-compatible"]
  • /home/node/.openclaw/memory/*.sqlite : index par agent
  • Image Docker : ghcr.io/openclaw/openclaw:2026.6.5

Demande au support OpenClaw

  1. Confirmer si memory status invalide l'index par design ou s'il s'agit d'un bug
  2. Fournir la procédure correcte pour un rebuild d'index vectoriel avec openai-compatible + endpoint OpenRouter
  3. Si bug confirmé, estimer un délai de correctif

Activity

  1. clawsweeper commented on Jun 9, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

    The reported successful rebuild followed by persistent runtime-only index metadata is missing matches the older canonical cached-manager/safe-reindex failure, which remains open with viable proof-backed repair work; the provider-initialization theory does not define a separate defect because provider-key comparison is deferred until the key is known.

    Canonical path: Keep #90361 as the canonical report, preserve this issue’s OpenAI-compatible and multi-agent evidence there, and review the proof-backed safe-reindex/runtime-handle repairs together before landing one coherent fix.

    So I’m closing this here and keeping the remaining discussion on #90361.

    Review details

    Best possible solution:

    Keep #90361 as the canonical report, preserve this issue’s OpenAI-compatible and multi-agent evidence there, and review the proof-backed safe-reindex/runtime-handle repairs together before landing one coherent fix.

    Do we have a high-confidence way to reproduce the issue?

    Yes. The issue gives a repeatable successful CLI rebuild followed by persistent runtime memory_search failure, matching the canonical report’s field reproduction and active repair evidence.

    Is this the best way to solve the issue?

    No, the proposed provider-initialization or unconditional auto-reindex fixes are not the narrowest solution; provider-key comparison is already deferred, while the canonical repair addresses readers observing stale or half-built SQLite state without weakening genuine identity mismatch protection.

    Security review:

    Security review: This issue has no proposed patch or security-sensitive report requiring a patch security review.

    AGENTS.md: found and applied where relevant.

    What I checked:

    Likely related people:

    • vincentkoc: Recent missing-metadata recovery and manager lifecycle work connects this contributor to the canonical repair surface. (role: recent area contributor; confidence: high; commits: d46dc39b18ec; files: extensions/memory-core/src/memory/manager.ts, extensions/memory-core/src/memory/manager-sync-ops.ts)
    • osolmaz: Authored the merged identity-validation feature that defines the affected missing and mismatched index states. (role: introduced behavior; confidence: high; commits: a4b4fed41287; files: extensions/memory-core/src/memory/manager.ts, extensions/memory-core/src/memory/manager-reindex-state.ts)
    • 849261680: Authored the active safe-reindex race repair with regression coverage and real CLI proof for the canonical issue. (role: related repair author; confidence: high; commits: 239c193a68d2; files: extensions/memory-core/src/memory/manager.ts, extensions/memory-core/src/memory/manager-sync-ops.ts, extensions/memory-core/src/memory/manager.reindex-read-race.test.ts)
    • dr00-eth: Authored related stale-handle and durable-metadata repair work and linked it directly from the canonical investigation. (role: adjacent repair author; confidence: high; commits: 203017314e5b; files: extensions/memory-core/src/memory/manager.ts, extensions/memory-core/src/memory/manager-sync-ops.ts, extensions/memory-core/src/memory/index.test.ts)

    Codex review notes: model internal, reasoning high; reviewed against e3a6da0f5181.

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    on Jun 9, 2026
  3. 1attila2 commented on Jun 10, 2026

    @1attila2
    Author

    Bonjour, un regard humain serait apprécié sur ce ticket. Le bug est confirmé par ClawSweeper comme présent dans le code source actuel (main). Nous avons 24 agents sans mémoire sémantique depuis 8 jours — c'est critique pour notre infrastructure.

    En attendant un correctif, nous allons downgrade vers une version antérieure (v2026.5.x). Pouvez-vous confirmer quelle est la dernière version stable sans ce bug ?

    Merci,
    Attila (1attila2)

  4. 1attila2 commented on Jun 10, 2026

    @1attila2
    Author

    Update 10 juin 2026 — Nous avons tenté un downgrade pour retrouver une version fonctionnelle de memory_search. Voici le rapport :

    Tentative de downgrade → ÉCHEC

    Nous avons essayé de revenir de v2026.6.5 vers v2026.5.28 puis v2026.5.7. Dans les deux cas, impossible :

    1. Config incompatible : Les clés introduites en v2026.6.x (description sur les agents, skills.workshop, talk.consultThinkingLevel, talk.consultFastMode, talk.realtime, verboseDefault) sont rejetées par v2026.5.x → le Gateway refuse de démarrer.

    2. Nettoyage de config inefficace : Même après avoir retiré toutes les clés non supportées, le Gateway v2026.5.7 démarre mais le frontend (navigateur) parle le protocole v2026.6.5 → protocol mismatch WebSocket → connexion rejetée.

    3. Sessions au nouveau format : Les sessions agents créées sous v2026.6.x utilisent un format de fichier que v2026.5.x ne peut pas lire.

    Conclusion

    Le downgrade vers une version pré-bug est structurellement impossible sans perdre toutes les sessions agents et sans vider le cache du navigateur de chaque utilisateur.

    Nous sommes bloqués sur v2026.6.5 avec le bug memory_search. Tous nos agents (24) sont sans mémoire sémantique depuis 8 jours. Le FTS fonctionne en fallback mais c'est très dégradé.

    Urgence : P0 pour nous. Un correctif ou une procédure de contournement documentée serait extrêmement apprécié.

    Merci,
    Attila

  5. removed
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    on Jun 10, 2026
  6. forge-builder commented on Jun 10, 2026

    @forge-builder

    Pinpointed root cause + 4-way git log -S convergence on a single commit.

    Regression commit: a4b4fed41287e267735a93d82cc4ff7e8e180c5b (PR #87907, Onur Solmaz, 2026-06-02T06:22:25Z). Title: fix(memory): validate memory index identity.

    Where it bites: extensions/memory-core/src/memory/manager.ts:654

    const indexIdentity = this.refreshIndexIdentityDirty({
      providerKeyKnown: this.providerInitialized,
    });
    if (indexIdentity.status !== "valid") {
      return [];                                            // <-- THE BUG
    }

    The new identity check (resolveMemoryIndexIdentityState in manager-reindex-state.ts:121) goes through resolveEmbeddingProviderAdapterId() which returns a different provider id than meta.provider for users on openai-compatible (OpenRouter), custom local model paths, or anyone who has done a provider alias cutover. The result: indexIdentity.status becomes "missing" (or "mismatch") on first search after the 2026.6.1 merge, the early-return fires, and the user sees "index metadata is missing" regardless of whether rows are actually present in main.sqlite. openclaw memory index --force doesn't help because the rebuild path goes through the same resolver and arrives at the same drift.

    On the steipete attribution to c9f288ceafbf: that commit is adjacent — it is the atomic reindex helper that a4b4fed interacts with — but git log -S "index metadata is missing" returns only a4b4fed and a follow-up test e2e log cap (f8f53de45). The actual code that turns "identity drift" into "no results forever" is a4b4fed.

    On PR #91227 (in flight): it addresses a related but distinct failure mode — a resident gateway holding a stale missing-metadata SQLite handle after the live DB has been rebuilt. It does not address the provider-resolver-drift path that breaks OpenRouter / openai-compatible / local-model users. #91778 is still fully open against the provider-resolver path even if #91227 lands.

    Minimal patch (stopgap, no schema/CLI surface change): replace the return [] with a sync({ reason: "search-identity-repair", force: true }) + re-evaluate, mirroring the hasIndexedContent() bootstrap 40 lines above. The PR #87907 description explicitly says "Repair is explicit… users rebuild the paused index with the existing indexing commands when they are ready" — but the early-return path makes that repair flow impossible to reach from the tool layer, which contradicts the stated intent.

    -    if (indexIdentity.status !== "valid") {
    -      return [];
    +    if (indexIdentity.status !== "valid") {
    +      await this.sync({ reason: "search-identity-repair", force: true });
    +      indexIdentity = this.refreshIndexIdentityDirty({ providerKeyKnown: this.providerInitialized });
    +      if (indexIdentity.status !== "valid") {
    +        return [];
    +      }
         }

    Equivalent fast hotfix: a one-line git revert a4b4fed if a backport is needed before the proper fix lands.

    Affected user signal: OpenRouter openai-compatible, custom local model paths, provider alias cutovers. Disproportionately users who picked non-default providers. The "fail-closed" rationale in PR #87907 is sound in principle (avoid mixing OpenAI/Ollama vectors), but the early-return is too aggressive — it should at minimum try to repair before giving up, and it should not fire when the only "drift" is the resolver returning a different but semantically equivalent provider id.

    My own environment is not affected (M3 via custom provider path that doesn't trigger the resolver drift; memory_search works in this session). Investigation was git log -S + gh api only — read-only on the OpenClaw repo, no PR opened.

  7. wc4482 commented on Jun 10, 2026

    @wc4482

    I'm surprised this issue hasn't gotten more attention. It single handedly makes my openclaw setup unusable.

  8. 1attila2 commented on Jun 10, 2026

    @1attila2
    Author

    🔬 Diagnostic complet — Noramind (Mami-Nora, Nóra & Devi)

    Contexte

    • OpenClaw 2026.6.5 dans conteneur Docker
    • 27 agents affectés, memory_search retourne systématiquement "index metadata is missing"
    • Provider embedding : openai + text-embedding-3-large (API key valide)
    • openclaw memory index --force réussit (27/27 agents, vector store ready)
    • 5+ restarts Gateway sans effet

    Root cause

    Dans le constructeur de MemoryIndexManager (manager.ts ~ligne 3548), computeProviderKey() est appelé avant le chargement du provider embedding.

    À ce stade, this.provider est null, donc computeProviderKey() calcule :

    hashText({provider: "none", model: "fts-only"})
    

    Ce hash est comparé au meta.providerKey stocké dans SQLite (qui contient {provider: "openai", model: "text-embedding-3-large"}) → mismatch → identity: "mismatched" → erreur.

    Le provider est chargé plus tard par ensureProviderInitialized(), qui rappelle computeProviderKey() avec le bon hash, mais le mal est fait : resolveCurrentIndexIdentityState() a déjà marqué l'index comme "mismatched".

    Tentatives de fix

    Patch #1 — computeProviderKey() utilisant this.requestedProvider : ❌

    Avant :

    if (!this.provider) return hashText({provider: "none", model: "fts-only"})
    

    Après :

    if (!this.provider) return this.requestedProvider
        ? hashText({provider: this.requestedProvider, model: "pending"})
        : hashText({provider: "none", model: "fts-only"})
    

    Échec : le hash avec model: "pending" ne correspond jamais au model: "text-embedding-3-large" stocké.

    Patch #2 — providerKeyKnown: false dans le constructeur : ✅

    Dans MemoryIndexManager constructor, appel à resolveCurrentIndexIdentityState() :

    Avant :

    providerKeyKnown: Boolean(params.providerResult)
    

    Après :

    providerKeyKnown: false
    

    Dans resolveMemoryIndexIdentityState() (ligne ~929) :

    if (params.providerKeyKnown !== false
        && meta.providerKey !== params.providerKey)
        return { status: "mismatched", ... }
    

    En forçant providerKeyKnown: false, la comparaison de providerKey est bypassée. Quand ensureProviderInitialized() charge le provider et rappelle computeProviderKey(), le hash correct est calculé et tout matche.

    Comment reproduire le fix upstream

    Dans extensions/memory-core/src/memory/manager.ts, constructeur :

    // Ligne ~3548 (dans l'ordre actuel) :
    this.providerKey = this.computeProviderKey();  // ← trop tôt, provider pas chargé
    // ...
    const initialIndexIdentity = this.resolveCurrentIndexIdentityState({
        meta,
        providerKeyKnown: Boolean(params.providerResult)
    });

    Solution upstream propre — option A : retarder computeProviderKey(). Ne pas l'appeler dans le constructeur. Le faire après ensureProviderInitialized().

    Solution upstream propre — option B : passer providerKeyKnown: false au premier check et recalculer l'identity après ensureProviderInitialized().

    Fichiers concernés

    • extensions/memory-core/src/memory/manager.ts — computeProviderKey() (ligne ~2558) et constructeur (ligne ~3548)

    Environnement de test

    • Docker ghcr.io/openclaw/openclaw:2026.6.5
    • Patchs appliqués directement dans /app/dist/manager-Bh_0NkeN.js (fichier minifié)

    Merci pour le super boulot sur OpenClaw ! 🌿

    — Attila (1attila2) / Mami-Nora @ Noramind

  9. mlaihk commented on Jun 12, 2026

    @mlaihk

    Adding a data point that may help narrow this down. We're on the supported path (memorySearch.provider: "openai-compatible") and still see this cascade. Specifically the sync path throws, but openclaw memory search at the CLI level returns real results.

    Our config

    {
      "agents": {
        "defaults": {
          "memorySearch": {
            "provider": "openai-compatible",
            "model": "text-embedding-qwen3-embedding-0.6b",
            "remote": {
              "baseUrl": "http://192.168.0.70:1234/v1",
              "apiKey": "***"
            },
            "fallback": "none"
          }
        }
      }
    }

    LM Studio running on the LAN with the qwen3-embedding model loaded. The models.providers table in our openclaw.json has no openai-compatible entry (only ollama, deepseek, minimax).

    What we see

    Embedding + search at CLI level works:

    $ openclaw memory search "fix the bug" --agent jordi
    → 6 results, top confidence 0.444
    $ openclaw memory status --index --agent jordi
    → "Vector store: ready, Semantic vectors: ready"
    

    But the background sync still throws this (every active-memory call, on average 1× per ~3 turns):

    [memory] sync failed (search): Error: No API key found for provider "openai".
    Auth store: /home/mlaih/.openclaw/agents/jordi/agent/openclaw-agent.sqlite
    

    The cascade target is "openai" — not "openai-compatible". Note the absence of the -compatible suffix in the error message. The cascade is asking for the legacy openai:default profile, not our configured provider.

    What we've already tried (matches your #4-5)

    1. memory index --force --agent jordi — reindexes, doesn't fix the sync-side error
    2. memory status --index — refreshes the runtime cache, no effect on sync cascade
    3. fallback: "none" is set in our config — still cascades

    Source-code trace (in case it helps)

    In dist/memory-core-host-engine-embeddings-*.js:resolveRemoteEmbeddingBearerClient:

    const remoteApiKey = resolveMemorySecretInputString({
      value: remote?.apiKey,
      path: "agents.*.memorySearch.remote.apiKey"
    });
    const apiKey = remoteApiKey ? remoteApiKey : requireApiKey(
      await resolveApiKeyForProvider({...}),
      params.provider
    );

    This should short-circuit when remote.apiKey is set (it is). But somewhere downstream the sync path is calling resolveApiKeyForProvider({ provider: "openai", ... }) with the legacy provider name. Possibly the post-sync refreshIndexIdentityDirty check, the fallback activation path, or the runSyncWithReadonlyRecovery reindex path.

    dist/manager-Bh_0NkeN.js:42 still has const DEFAULT_MEMORY_EMBEDDING_PROVIDER = "openai"; and line 136 resolves options.provider === "auto" to "openai". There may be a code path where the configured "openai-compatible" provider name gets dropped and the "openai" default is re-derived.

    Working theory

    PR #85269 added the openai-compatible embedding provider path, but the DEFAULT_MEMORY_EMBEDDING_PROVIDER constant in manager-Bh_0NkeN.js and possibly some sync-path code still defaults to "openai" (not "openai-compatible"). When a downstream code path asks for the embedding provider without the configured openai-compatible name, it falls through to the legacy "openai" default, which then needs the openai:default auth profile we don't have.

    Workaround until this is fixed

    We re-add a fake openai:default profile to the agent's auth store:

    import sqlite3, json, time
    agent_db = "/home/mlaih/.openclaw/agents/jordi/agent/openclaw-agent.sqlite"
    conn = sqlite3.connect(agent_db)
    cur = conn.cursor()
    cur.execute("SELECT store_json FROM auth_profile_store WHERE store_key='primary'")
    current = json.loads(cur.fetchone()[0])
    current["profiles"]["openai:default"] = {
        "type": "api_key", "provider": "openai",
        "key": "sk-fake-jordi-lmstudio-fallback-not-a-real-openai-key"
    }
    cur.execute("UPDATE auth_profile_store SET store_json=?, updated_at=? WHERE store_key='primary'",
                (json.dumps(current, separators=(",", ":")), int(time.time() * 1000)))
    conn.commit()

    This silences the cascade (sync throws, caught, retried successfully). The 47% active-memory unavailable rate drops back to ~0% after applying it.

    We'd rather not patch the auth store long-term — it's a workaround, not a fix. A proper fix would be to either (a) change the default in manager-Bh_0NkeN.js to "openai-compatible" or "auto", or (b) make the sync-path code use the configured provider instead of the default.

    Happy to test a fix if you can point me at a build.

  10. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions