Skip to content

memory_search broken with "index scope changed" after --force rebuild — scopeHash mismatch persists #91592

Closed as not planned

Description

@StarbloomConsultingHub

Description

After running openclaw memory index --force, the memory_search tool returns:

"error": "index scope changed"
"warning": "memory index was built with a different embedding provider/model/settings"

The scope hash stored in the SQLite meta table never matches any computation against the current files table, regardless of rebuild attempts.

Version

  • OpenClaw: 2026.6.1 (2e08f0f)
  • Provider: ollama / nomic-embed-text (768-dim vectors)
  • Vector store: sqlite-vec (vec0.so)
  • Platform: Linux (WSL2 Ubuntu 22.04)

To Reproduce

  1. Configure memorySearch with provider: ollama, model: nomic-embed-text
  2. Index some memory files (in our case 144 files across MEMORY.md + dream logs)
  3. Run memory_search — returns scope error
  4. Run openclaw memory index --force — reports "Memory index updated"
  5. Run memory_search again — same error

Root Cause Evidence

The hash e861c1d291b583b9f4bf96233b72b9e6984cc92320671a0805e1063946e4b1a1 is written by the indexer into meta.memory_index_meta_v1.scopeHash and never changes across rebuilds — even after:

  • Deleting the meta row entirely and rebuilding
  • Deleting the entire main.sqlite file and building from zero
  • Patching the hash directly in SQLite

The computed hash from the actual files table always differs from the stored hash. The indexer and the gateway scope validator appear to be computing the hash differently — likely the indexer includes a field or ordering that the validator uses differently, or vice versa.

Core diagnostics we ran:

files = conn.execute(SELECT path, source, hash FROM files ORDER BY path).fetchall()
file_list = [{"path": p, "source": s, "hash": h} for p, s, h in files]
computed = hashlib.sha256(json.dumps(file_list, sort_keys=True).encode()).hexdigest()
# computed != stored scopeHash — always

openclaw memory status --index reports everything as ready (144 files, 768-dim vectors, embeddings/vector store ready). 33MB SQLite.

Expected Behavior

After --force rebuild, the scope hash should be recomputed from the actual indexed files and memory_search should return results.

Workarounds Attempted (none worked)

  • Multiple --force rebuilds
  • Deleting SQLite entirely and rebuilding from scratch
  • Directly patching scopeHash in SQLite to match computed values
  • Full gateway cold restart after rebuild

For now we are using a separate graph memory system (LadybugDB MCP) for structured retrieval as a workaround.

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.

    Close as duplicate/superseded: the current symptom is still real, but the remaining provider/runtime identity and scope validation work is already tracked by the open canonical issue, with the live-manager reload slice tracked separately.

    Root-cause cluster
    Relationship: duplicate
    Canonical: #91902
    Summary: This issue is a satellite of the open provider/runtime memory identity tracker; its newest v2026.6.10 reproduction and the canonical issue both cover CLI-healthy indexes being rejected by in-session memory_search through providerKey/scopeHash identity drift.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Canonical path: Keep the remaining provider/runtime memory identity work consolidated on #91902, with live-manager publication/reload details preserved on #91167.

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

    Review details

    Best possible solution:

    Keep the remaining provider/runtime memory identity work consolidated on #91902, with live-manager publication/reload details preserved on #91167.

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

    Yes at source level and from latest-release field evidence; I did not run a live current-main Ollama/Voyage setup. Current source still pauses search on invalid index identity, and the latest comment reports v2026.6.10 reproducing after CLI status/search succeed.

    Is this the best way to solve the issue?

    Yes for triage: closing this satellite is the best cleanup path because the remaining provider/runtime identity work is already tracked by the open canonical issue. The implementation fix still needs a maintainer-approved identity policy that keeps CLI rebuild, runtime provider resolution, scopeHash, and live manager state coherent.

    Security review:

    Security review: This is a non-PR bug triage item with no patch or security-sensitive report under review.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Current identity gate still matches the reported error: Current main still returns index metadata is missing for missing meta and index scope changed when persisted scopeHash differs from configured scope. (extensions/memory-core/src/memory/manager-reindex-state.ts:160, 938855082ade)
    • Current search still pauses on invalid identity: MemoryIndexManager.search() refreshes index identity and returns no results when the identity state is not valid, which is the source-level fail-closed behavior behind the unavailable tool result. (extensions/memory-core/src/memory/manager.ts:667, 938855082ade)
    • Latest release still contains the same gate: v2026.6.10 contains the same missing-meta, providerKey, and scopeHash identity checks plus the search early return, so this is not implemented on the latest release. (extensions/memory-core/src/memory/manager-reindex-state.ts:160, aa69b12d0086)
    • Canonical provider/runtime identity tracker is open: The open canonical issue covers memory index --force writing incompatible runtime metadata, providerKey drift, non-default provider reproductions, and a confirmed scopeHash discrepancy.
    • Latest issue comment points to the canonical tracker: A 2026-06-29 reproduction on v2026.6.10 reports CLI status/search as healthy while in-session memory_search fails with index scope changed, and explicitly says it probably overlaps the canonical providerKey tracker.
    • Related live-manager reload work remains separate: The open live-manager publication/reload issue is still kept open by maintainer discussion for stale SQLite handle and missing identity recovery, so that sub-slice does not need this satellite issue either.

    Likely related people:

    • osolmaz: Commit a4b4fed added the memory index identity validation state model and central missing/mismatched checks involved in this failure class. (role: identity behavior contributor; confidence: high; commits: a4b4fed41287; files: extensions/memory-core/src/memory/manager-reindex-state.ts, extensions/memory-core/src/memory/manager-sync-ops.ts, extensions/memory-core/src/memory/manager.ts)
    • vincentkoc: Recent memory-core work includes migrated index rebuild handling and related release/current-main touches around the reindex and identity area. (role: recent area contributor; confidence: high; commits: 6e6bd5633f1c, aa69b12d0086; files: extensions/memory-core/src/memory/manager-sync-ops.ts, extensions/memory-core/src/memory/manager.ts, extensions/memory-core/src/memory/manager-reindex-state.ts)
    • xydt-tanshanshan: Recent work prevents empty expected models in memory index identity and an open related PR targets provider.model backfill in the same provider identity cluster. (role: recent related fix author; confidence: medium; commits: 85a635368e2f, 5fce864c97e3; files: extensions/memory-core/src/memory/manager-reindex-state.ts, extensions/memory-core/src/memory/embeddings.ts, extensions/memory-core/src/memory/embeddings.test.ts)

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

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    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.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    on Jun 9, 2026
  3. mtoko commented on Jun 12, 2026

    @mtoko

    Another instance: Voyage provider, per-agent SQLite, mixed embedding model versions

    Environment

    • OpenClaw: 2026.6.1 (2e08f0f)
    • OS: Ubuntu 24.04 LTS, x86_64, glibc 2.39
    • Node: v22.22.0
    • Memory backend: builtin (sqlite-vec 0.1.9)
    • Embedding provider: voyage / voyage-3

    Context

    We have three agents configured: main, analyst, and client. Only the analyst agent was affected. main and client both had working memory search throughout.


    What we saw

    Every time the gateway restarted, memory_search in the analyst session returned:

    {
      "error": "index metadata is missing",
      "warning": "memory index was built with a different embedding provider/model/settings"
    }

    Running openclaw memory index --force (or --agent analyst) would temporarily fix it, but the next gateway restart broke it again.

    openclaw memory status --index always reported the analyst as healthy after a force rebuild. We also wasted time chasing Vector store: unknown as the root cause — see #92102 for the false-negative CLI display issue.


    Root cause we found

    Two layered problems:

    1. Mixed embedding model versions in analyst.sqlite

    Inspecting the file with strings revealed the embedding_cache table contained entries for both voyage-4-large (an old model no longer in config) and voyage-3 (the current model). The memory_index_meta_v1 row correctly named voyage-3, but the cached vectors were contaminated.

    The analyst SQLite had accumulated these voyage-4-large entries from a previous configuration. The gateway appears to detect this inconsistency on startup and clears/ignores the metadata row, leaving the index in a broken state.

    2. No explicit workspace for the analyst agent

    Our analyst agent had no explicit workspace field in config. The CLI (openclaw memory index) auto-resolved the workspace to /home/darryl/clawd/analyst (from the AGENTS.md location), but we believe the gateway may have been resolving it differently at startup, producing a different scopeHash.

    // Before fix — agent had no workspace field:
    { "id": "analyst", "name": "Pete (Deep Think)", "thinkingDefault": "adaptive", "reasoningDefault": "on" }
    
    // After fix:
    { "id": "analyst", ..., "workspace": "/home/darryl/clawd/analyst" }

    Why only analyst and not main or client?

    • main was built a long time ago with the old voyage-4-large entries only — no mixed models, consistent metadata
    • client has an explicit workspace in config
    • analyst had neither: no explicit workspace, and an embedding_cache contaminated with a superseded model

    Workaround that resolved the issue

    After cleaning the analyst SQLite and adding the explicit workspace, the scopeHash mismatch continued (the gateway still cleared metadata on startup). The fix that finally unblocked us was disabling the vector store for the analyst agent:

    "memorySearch": {
      "store": {
        "vector": {
          "enabled": false
        }
      }
    }

    With vector.enabled: false, the analyst falls back to FTS-only mode. Memory search now works correctly and survives gateway restarts. The trade-off is semantic vector ranking is disabled for this agent only.


    Suggested investigation

    The gateway appears to be silently clearing memory_index_meta_v1 from a per-agent SQLite on startup when it encounters the vec store state or embedding cache inconsistencies — without logging anything to journalctl. Operators have no way to know this is happening.

    Two asks:

    1. Log a warning when the gateway invalidates/clears per-agent index metadata at startup, so it's diagnosable without strings-inspecting the SQLite
    2. Consider whether the embedding cache should be stored separately from the index metadata, so stale cache entries from superseded models don't pollute the index validity check
  4. mtoko commented on Jun 12, 2026

    @mtoko

    Update: original workaround was not stable — additional findings

    Following up on my earlier comment. The memorySearch.store.vector.enabled: false workaround I described was not stable. Here's a more complete picture after further investigation.


    What we now know about the recurring trigger

    The metadata invalidation is not just happening at gateway startup. It also happens during the session, after the first memory_search call. The sequence we observed repeatedly:

    1. Gateway restarts → analyst memory module initialises (sometimes successfully, sometimes not)
    2. First memory_search call succeeds and returns results
    3. Shortly after (~seconds to minutes), a subsequent memory_search call returns "index metadata is missing" again

    We believe the first successful search triggers a background sync operation which then re-validates the scopeHash. The re-validation fails, the metadata gets cleared, and all further searches in the session fail.

    Key diagnostic: SIGUSR1 hot-reload (the gateway restart tool) does not reinitialise the memory module. The module's failed/broken state is pinned from when it was first initialised. Only a full process restart (systemctl --user restart openclaw-gateway.service) clears it — but the problem then recurs in the new session.


    Further workaround attempts

    We tried pointing the analyst agent at the working main.sqlite directly:

    "memorySearch": {
      "store": { "path": "/home/darryl/.openclaw/memory/main.sqlite" },
      "sync": { "onSessionStart": false, "onSearch": false, "watch": false }
    }

    This worked transiently (memory search returned results with vector scores immediately after restart), but broke again within the same session. The sync: false settings did not prevent the re-invalidation.


    What we think is happening

    The gateway appears to have a background validation loop (separate from the configured sync triggers) that periodically re-checks the scopeHash against the live database state. When it detects a mismatch, it clears the metadata and marks the module as unavailable — silently, with no log output to journalctl.

    This is distinct from the startup mismatch described in the original issue. The problem survives sync being disabled.


    Minimal reproduction

    • Multi-agent OpenClaw setup (main + analyst agents, same workspace ~/clawd)
    • Analyst agent has no explicit workspace in config (auto-resolved by CLI to ~/clawd/analyst, but gateway uses ~/clawd default)
    • Embedding provider: voyage / voyage-3
    • Steps: restart gateway → run memory_search → success → run second memory_search → "index metadata is missing"

    What would fix this

    At the OpenClaw level, two things would resolve this permanently:

    1. The scopeHash validation should not clear the metadata mid-session. If it detects a mismatch, it should log a warning and continue with the stale index rather than silently breaking all searches.

    2. The background validator should be controlled by the same sync.* knobs as the foreground sync. If sync.onSearch: false and sync.watch: false, no validation loop should run.

    We're on OpenClaw 2026.6.1 (2e08f0f), x86_64, Ubuntu 24.04, Node 22.22.0, voyage/voyage-3.

  5. mtoko commented on Jun 12, 2026

    @mtoko

    Update 2: still broken in 2026.6.5, exact reproduction pattern confirmed

    Upgraded to 2026.6.5 (5181e4f) today. Issue persists.

    Exact reproduction pattern now confirmed

    After a full gateway restart (systemctl --user restart):

    1. First memory_search call in the session succeeds (vectorScore present, results returned)
    2. Second memory_search call in the same session fails with "index metadata is missing"
    3. Running openclaw memory index --force --agent analyst and retrying → fails immediately (no working call even)

    This confirms the background validator fires between calls 1 and 2, clears the metadata, and the module enters a permanently broken state for the rest of the session. No amount of CLI rebuilding recovers it without a full gateway restart — and the restart just resets the cycle.

    What 2026.6.5 changed (memory-related)

    From the release notes: "memory adapter status uses the resolved default model identity when checking plain status" (#61834). This did not affect our issue.

    Current workaround config (not sufficient but documented for others)

    {
      "id": "analyst",
      "memorySearch": {
        "store": { "path": "/home/darryl/.openclaw/memory/main.sqlite" },
        "sync": { "onSessionStart": false, "onSearch": false, "watch": false }
      }
    }

    sync: false does not prevent the background validation loop. The validator appears to run independently of sync settings.

    Suggestion for maintainers

    The background validator that invalidates metadata mid-session needs to be either:

    • Gated behind the sync config knobs, or
    • Changed to a non-destructive warn-only path that logs but does not clear metadata

    The current silent mid-session invalidation makes the memory module unusable in multi-query workflows.

  6. added
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    on Jun 19, 2026
  7. wangwllu commented on Jun 29, 2026

    @wangwllu
    Contributor

    Additional reproduction on 2026.6.10

    I can still reproduce the mismatch on a current local install.

    Environment:

    • OpenClaw: 2026.6.10 (aa69b12)
    • OS: Darwin 24.6.0 arm64
    • Memory backend: builtin
    • Embedding provider/model: ollama / nomic-embed-text
    • Vector dims: 768

    After a forced rebuild, the CLI side looks healthy:

    openclaw memory status --index --json
    

    Redacted status highlights:

    • files=281, chunks=1624
    • dirty=false
    • extraPaths=[]
    • provider=ollama, model=nomic-embed-text, requestedProvider=ollama
    • fts.available=true
    • vector.available=true, semanticAvailable=true, storeAvailable=true
    • custom.indexIdentity.status=valid
    • embeddingProbe.ok=true

    CLI search also returns results for the same memory corpus:

    openclaw memory search --query "Memory P1-P4 maintenance batch Active Work Board Quick Index backup" --max-results 3 --json
    

    But the first-class in-session memory_search tool still fails immediately with:

    {
      "results": [],
      "disabled": true,
      "unavailable": true,
      "error": "index scope changed",
      "warning": "Tell the user: memory search is paused because the memory index was built with a different embedding provider/model/settings.",
      "action": "Tell the user to run: openclaw memory status --index or openclaw memory index --force."
    }

    So the user-facing recovery instruction points to memory status --index / memory index --force, but that path has already been run and now reports a valid index identity plus a successful embedding probe. This looks aligned with the existing provider/runtime identity or scope validation cluster, and probably overlaps the canonical providerKey tracker in #91902 rather than needing a separate issue.

  8. locked as resolved and limited conversation to collaborators on Jul 18, 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.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.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