Skip to content

[Bug] memos-local-plugin : chunks table never created — causes viewer dashboard data drift and auto-recall injection failure #2131

Description

@MacQimw

[Bug] memos-local-plugin 2.0: chunks table never created — causes viewer dashboard data drift and auto-recall injection failure

Pre-submission checklist

  • I have searched existing issues and this hasn't been mentioned before
  • I have read the project documentation and confirmed this issue doesn't already exist
  • This issue is specific to MemOS and not a general software issue

Bug Description

Summary

In memos-local-plugin v2.0.x, the chunks table is never created by any of the 12 schema migrations. This causes the MemOS Viewer dashboard (port 18799) to display data correctly for a brief moment after gateway restart, then drift to empty/zero as soon as a message is processed. Auto-recall injection also fails to retrieve relevant context.

Symptoms

  1. Viewer dashboard data drift: After openclaw gateway restart, the dashboard at http://127.0.0.1:18799 shows correct data momentarily. Within 10-20 seconds — or immediately upon sending a message to the agent — all data disappears and shows empty/zero.
  2. Auto-recall returns empty or irrelevant results: Cross-session memory recall fails. Manual vector search via Ollama bge-m3 works correctly (relevant results found in top-K), but the plugin's auto-recall pipeline does not inject them.
  3. embedding_retry_queue fills up: 72 failed retry entries referencing a corrupted local ONNX model (separate issue, see below).

Key Finding

The chunks table — which the Viewer dashboard and retrieval pipeline depend on — does not exist in the 2.0 database. Examination of all 12 SQL migration files reveals that none of them contain a CREATE TABLE chunks statement.

This is a regression from 1.0 (memos-local-openclaw-plugin), where chunks is properly created via CREATE TABLE IF NOT EXISTS chunks in sqlite.ts.

How to Reproduce

  1. Install @memtensor/memos-local-plugin v2.0.10 on OpenClaw (tested on v7.1)
  2. Configure embedding provider as openai_compatible (Ollama bge-m3) in config.yaml
  3. Start the gateway: openclaw gateway start
  4. Open http://127.0.0.1:18799 → Dashboard shows data normally ✅
  5. Send any message to the agent → Dashboard data immediately drifts to empty ❌
  6. Verify: sqlite3 ~/.openclaw/memos-plugin/data/memos.db ".tables" → no chunks table

Environment

  • OpenClaw: v7.1 (stable release)
  • memos-local-plugin: v2.0.10 (npm latest)
  • OS: macOS 15 (Darwin 24.6.0, ARM64)
  • Node.js: v25.8.1
  • Embedding: Ollama bge-m3 (1024-dim) via OpenAI-compatible endpoint
  • LLM: GLM-5.2 via third-party provider

Investigation Details

We conducted a thorough 5-round investigation (on a clone of the production environment) to isolate the root cause:

Round 1: Database schema audit

Inspected the 2.0 database (~/.openclaw/memos-plugin/data/memos.db):

Tables that exist (9 with data):

Table Rows
traces 64,958
episodes 35,142
sessions 1,194
skills 481
api_logs 1,454
schema_migrations 12
embedding_retry_queue 72
kv, audit_events, feedback, etc. 0

Tables that are MISSING:

Table Impact
chunks Dashboard cannot display memory content
embeddings No vector data for viewer
tasks
skill_embeddings
task_embeddings

Round 2: Migration history

All 12 migrations execute at startup:

001-initial.sql
002-embedding-retry-queue.sql
003-embedding-retry-lease.sql
004-skill-usage.sql
005-skill-trials.sql
006-world-model-version.sql
007-namespace-visibility.sql
008-feedback-experience-metadata.sql
009-policies-fts.sql
010-trace-policy-links.sql
011-hub-sharing.sql
012-trace-turn-pagination-index.sql

None of these migrations create a chunks table. The 001-initial.sql creates 13 tables: schema_migrations, sessions, episodes, traces, policies, l2_candidate_pool, world_model, skills, feedback, decision_repairs, audit_events, api_logs, kv.

Round 3: ONNX model corruption (independent issue)

Found that the local ONNX model (Xenova/all-MiniLM-L6-v2) was corrupted (8.1 MB instead of ~22 MB, Protobuf parsing failed). We deleted and re-downloaded the correct model. After restart:

  • ✅ ONNX model healthy (22 MB)
  • ✅ No new entries in embedding_retry_queue
  • chunks table still doesn't exist
  • ❌ Dashboard drift not fixed

Conclusion: ONNX corruption and missing chunks table are two independent problems.

Round 4: Configuration analysis

Config (config.yaml) specifies:

embedding:
  provider: openai_compatible
  endpoint: http://192.168.3.7:11434/v1
  model: bge-m3

However, the plugin still attempts to load the local ONNX model first, despite openai_compatible being configured. The Ollama endpoint works perfectly (verified independently). This suggests the embedding provider selection logic may have a fallback issue.

Round 5: Code-level evidence on current main branch

We verified the latest code on main (as of 2026-07-20):

  • 1.0 plugin (apps/memos-local-openclaw/src/storage/sqlite.ts): Contains CREATE TABLE IF NOT EXISTS chunks
  • 2.0 plugin (apps/memos-local-plugin/core/storage/migrations/001-initial.sql): Does NOT contain CREATE TABLE chunks
  • 2.0 plugin (server/routes/migrate.ts): Comments reference "The schema (chunks/skills/tasks) is the same across both" — indicating chunks was expected to exist in 2.0 as well

Comparison: 1.0 vs 2.0 database

Aspect 1.0 (memos-local-openclaw) 2.0 (memos-local-plugin)
chunks table ✅ Created (42K+ rows in production) Never created
embeddings table ✅ Created ❌ Missing
traces table ✅ 64K+ rows
Architecture Single chunks table Split into traces/episodes/sessions

Root Cause Analysis

The 2.0 plugin underwent an architecture change — the flat chunks table from 1.0 was split into a normalized tracesepisodessessions hierarchy. However:

  1. The Viewer dashboard and retrieval pipeline still contain code paths that query the chunks table
  2. No migration creates chunks in the 2.0 schema
  3. The migrate.ts route (for importing 1.0 data) explicitly references the chunks table schema in comments

This results in:

  • Startup: Dashboard reads from in-memory cache or traces pre-load → appears normal
  • Message received: Triggers a refresh/re-query targeting chunks → table doesn't exist → empty result → dashboard drifts to zero

Suggested Fix Direction

Option A: Add a migration to create the chunks table (if it's still needed by viewer/retrieval code paths)

Option B: Update all code paths that reference chunks to use the new traces/episodes/sessions schema instead

Additional Context

Related issues

Production impact

This bug makes memos 2.0 unusable in production — the viewer is non-functional and auto-recall doesn't work. We are forced to stay on 1.0 (memos-local-openclaw-plugin v1.0.10) until this is resolved.

We have detailed investigation reports (including full database dumps, schema comparisons, and step-by-step reproduction) available if the team needs them.

Willingness to Implement

  • I'm willing to implement this myself
  • I would like someone else to implement this

Metadata

Metadata

Labels

area:pluginOpenClaw & Hermesstatus:in-progressSomeone or AI is working on it | 人工或 AI 正在处理types:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions