You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Worker refuses to start after embedding provider change: stale index dimension mismatch (2048D vs 384D) #455
After switching embedding providers (or after an agentmemory upgrade that changed the default local model), the worker refuses to start with a fatal error:
[agentmemory] Fatal: Error: [agentmemory] Refusing to start: persisted vector index has 19 of 19 vectors with the wrong dimension. Active provider (local) declares 384; dimensions seen on disk: 2048. First mismatched obsIds: mem_mp8ctmgi_37deb553385b (dim=2048), ...
The worker process exits immediately, leaving the REST API (:3111) unreachable. The dashboard (:3113) stays in "CONNECTING..." state with all counters at 0.
Root Cause
The local embedding provider switched from a 2048D model to all-MiniLM-L6-v2 (384D). The persisted vector index on disk still contains vectors from the old provider. The worker detects this mismatch and refuses to start to prevent silent search corruption.
Workaround
Add to ~/.agentmemory/.env:
AGENTMEMORY_DROP_STALE_INDEX=true
Then restart the worker. All existing memories are lost — the index is purged and rebuilt from scratch.
Expected Behavior
Graceful degradation: The worker should start even with a stale index, falling back to BM25-only search until re-embedding completes
Auto-migration: Detect dimension mismatch and offer to re-embed existing vectors against the new provider (with a progress indicator)
Clear CLI guidance: The error message mentions 3 options but requires manual .env editing. A CLI flag like agentmemory start --drop-stale-index or agentmemory reset-index would be more discoverable
Dashboard visibility: The dashboard should show a warning banner when the index is stale, rather than silently showing "0 sessions" with "CONNECTING..."
Environment
agentmemory: v0.9.17
iii-engine: v0.11.6
Host: OpenCode Desktop 1.15.3
OS: macOS 15.4 (arm64)
Embedding provider: local (all-MiniLM-L6-v2, 384D)
Previous provider: unknown (2048D vectors on disk)
Reproduction Steps
Run agentmemory with an embedding provider that produces 2048D vectors
Create some sessions/memories
Switch to local provider (384D) or upgrade agentmemory to a version with a different default model
Restart agentmemory → worker crashes with dimension mismatch error
REST API unreachable, dashboard shows "CONNECTING..."
Suggested Fix
Add a --reset-index or --migrate-index CLI flag
Implement background re-embedding of stale vectors when provider changes
Show index health status in the dashboard
Provide a non-destructive fallback mode (BM25-only) when vector index is incompatible
Related-but-not-a-fix: I just opened #525 which makes OpenRouterEmbeddingProvider.dimensions env-aware (mirrors what OpenAIEmbeddingProvider already does via _openai-shared). That addresses the same class of dim-mismatch symptom for users on OpenRouter with non-1536-dim models (e.g. qwen/qwen3-embedding-8b at 4096-dim — silently dropped from the vector index today), but it does not address your specific case here: a provider switch from 2048-dim to 384-dim where the on-disk vectors are now incompatible regardless of what the new provider declares.
Your "graceful degradation / auto-migration / CLI flag" points are the right shape for that. Worth linking #456 too — they describe AGENTMEMORY_DROP_STALE_INDEX=true in .env having no effect because the dimension guard reads process.env directly instead of getMergedEnv(), which compounds the "no workaround from .env" problem you've hit.
Activity
Ptah-CT commentedon May 19, 2026
Related-but-not-a-fix: I just opened #525 which makes
OpenRouterEmbeddingProvider.dimensionsenv-aware (mirrors whatOpenAIEmbeddingProvideralready does via_openai-shared). That addresses the same class of dim-mismatch symptom for users on OpenRouter with non-1536-dim models (e.g.qwen/qwen3-embedding-8bat 4096-dim — silently dropped from the vector index today), but it does not address your specific case here: a provider switch from 2048-dim to 384-dim where the on-disk vectors are now incompatible regardless of what the new provider declares.Your "graceful degradation / auto-migration / CLI flag" points are the right shape for that. Worth linking #456 too — they describe
AGENTMEMORY_DROP_STALE_INDEX=truein.envhaving no effect because the dimension guard readsprocess.envdirectly instead ofgetMergedEnv(), which compounds the "no workaround from.env" problem you've hit.fix(vector-index): preserve byteOffset/byteLength in base64 round-trip (
fix(vector-index): preserve byteOffset/byteLength in base64 round-trip (
fix: start and re-embed on a vector dimension change instead of refusing