Skip to content

Memory index meta never written when gateway auto-sync finds identity missing with existing chunks #90338

@junxuku-byte

Description

@junxuku-byte

Bug Report

Version: OpenClaw 2026.6.1 (2e08f0f)
OS: macOS 15.4.0 (arm64, M4 Mac Mini)

Summary

The gateway's memory auto-sync creates a dead loop: it indexes files (creating chunks) but never writes the meta table entry (memory_index_meta_v1), so indexIdentityState remains "missing" forever. All memory_search calls return "index metadata is missing" with 0 results.

Root Cause (from source analysis)

In manager-dZw31DAG2.js, the runSync() method at ~line 2073:

if (indexIdentity.status !== "valid" && !needsFullReindex) {
    this.dirty = true;
    // ... mark sessions dirty
    return;  // ← Returns without writing meta!
}

The condition needsFullReindex is false when hasIndexedChunks is true (which it is, because the sync itself just created chunks). So after the first sync cycle:

  1. Identity is "missing" (no meta)
  2. hasIndexedChunks = true (sync created chunks)
  3. needsInitialIndex = false (has chunks)
  4. needsExplicitIdentityReindex = false (not CLI-triggered)
  5. Early return without writing meta
  6. Next sync → same loop

Reproduction

  1. Start with an empty meta table in omes-vec.db (e.g., after DB corruption or version upgrade)
  2. openclaw gateway start
  3. Gateway auto-sync runs, indexes files, creates chunks
  4. memory_search returns "index metadata is missing"
  5. Running openclaw memory index --force from CLI writes meta correctly
  6. But gateway restart clears meta again (gateway re-syncs from scratch)

Workaround Attempted

  • openclaw gateway stop → clear DB → openclaw memory index --forceopenclaw gateway start
  • Gateway starts, sees existing chunks, but still enters the dead loop because its sync finds identity "missing" and hasIndexedChunks=true

Environment

  • Embedding provider: openai-compatible (local oMLX on localhost:8000, model bge-m3-mlx-fp16)
  • DB: ~/.openclaw/memory/omes-vec.db (SQLite with sqlite-vec)
  • Extra paths: 4 external directories (~1200 files total)
  • 6 agents configured, all show providerState: pending after gateway starts

Expected Behavior

When gateway auto-sync encounters identity "missing" but has indexed chunks (from its own sync or CLI), it should either:

  1. Write meta after completing the sync (even if identity is still "missing"), OR
  2. Treat "identity missing + has chunks from current sync" as needsInitialIndex = true

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.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
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions