Skip to content

Gateway memory_search index stuck dirty: provider.model empty during boot overwrites correct index identity #90042

Description

@Bizman365

Summary

The gateway's memory_search tool is permanently stuck with Dirty: yes because this.provider.model is empty/uninitialized when the OpenAI embedding adapter resolves, but every identity check and meta write uses it raw — overwriting the correct model identity stamped by the CLI.

Reproduction

  1. Configure memorySearch with provider: "openai" and model: "text-embedding-3-small"
  2. Build a clean index with the CLI: openclaw memory status --index --agent mainDirty: no
  3. Start the gateway
  4. Run openclaw memory statusDirty: yes, Index identity: index was built for model text-embedding-3-small, expected

The expected model is an empty string because this.provider.model is not populated by the OpenAI adapter after create().

Root cause

resolveProviderModel() correctly resolves the model name during adapter.create(), but the resolved name is not backfilled onto the returned provider object's .model field. The adapter returns provider.model = "" (or the raw provider ID).

Every downstream use of this.provider.model then propagates the empty string:

  • Identity checks (refreshIndexIdentityDirty, resolveCurrentIndexIdentityState, runSync) compare "" against "text-embedding-3-small" → always "mismatched"Dirty: yes
  • Meta writes (writeMeta in safe-reindex and runUnsafeReindex) stamp "" into sqlite → next boot sees identity mismatch
  • Chunk writes/queries (writeChunks, searchVector, searchKeyword) use inconsistent model tags
  • The dirty verdict is cached and only re-evaluated at boot or on search — but boot wipes the meta first, so there is no path to recovery from outside

Affected code

dist/manager-dZw31DAG2.js — 13 occurrences of this.provider.model / this.provider?.model with no fallback to this.settings.model:

  • Lines 1143, 2049, 3567 (identity checks)
  • Lines 2271, 2338 (meta writes)
  • Lines 2002, 2528, 2850, 2951, 2962, 3706, 3721 (data paths)

Workaround

Patch all 13 sites to fall back: this.provider.model || this.settings.model

For example in refreshIndexIdentityDirty:

// Before:
model: this.provider.model
// After:
model: this.provider.model || this.settings.model

Suggested fix

Either:

  1. Backfill provider.model with the resolved model name in createWithAdapter / adaptGenericEmbeddingProvider after resolveProviderModel() runs
  2. Or add the || this.settings.model fallback in MemoryIndexManager at each usage site

Option 1 is cleaner — single fix at the source.

Environment

  • OpenClaw v2026.6.1 (2e08f0f)
  • macOS (darwin arm64)
  • Node 22.22.2
  • Provider: openai, model: text-embedding-3-small

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.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: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions