Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(serve): warn on embedding mismatch instead of aborting startup

pedrofjr019b523f4ab9
diff --git a/crates/ai-memory-cli/src/commands/serve.rs b/crates/ai-memory-cli/src/commands/serve.rs
index 08d3124a..1020f08b 100644
--- a/crates/ai-memory-cli/src/commands/serve.rs
+++ b/crates/ai-memory-cli/src/commands/serve.rs
@@ -444,10 +444,18 @@ async fn configure_embedder(
)
.await?;
if !mismatch.is_empty() {
- anyhow::bail!(
- "embedding (provider, model, dim) mismatch with stored data: {:?} \
- — run `ai-memory embed --reembed` to migrate",
- mismatch
+ // Refuse-on-mismatch applies to hybrid search (queries only load
+ // rows matching the configured triple), not to process liveness.
+ // Blocking startup made `embed --reembed` impossible because the
+ // CLI is an HTTP client to this server.
+ tracing::warn!(
+ stored = ?mismatch,
+ configured_provider = cfg.provider.name(),
+ configured_model = %cfg.model,
+ configured_dim = cfg.dim,
+ "stored embeddings use a different (provider, model, dim) than configured; \
+ hybrid search ignores stale rows until pages are re-embedded — \
+ run `ai-memory embed --reembed` (or wait for scheduled backfill)"
);
}
info!(
diff --git a/docs/deploy.md b/docs/deploy.md
index b886428a..94578fc7 100644
--- a/docs/deploy.md
+++ b/docs/deploy.md
@@ -216,11 +216,11 @@ ssh "$SERVER" "tail -100 $DEPLOY_DIR/data/logs/ai-memory.log.$(date +%F)"
`ai-memory status` healthcheck is failing. Most likely the data
dir's permissions don't match the container's user (uid 1000). Fix
with `sudo chown -R 1000:1000 $DEPLOY_DIR/data` on the host.
-- **Embedding mismatch refusing to start**: ai-memory refuses to boot
- when the configured `(provider, model, dim)` for embeddings doesn't
- match the stored pages' embeddings. Either revert the change or run
- `ai-memory embed --reembed` (after starting with the old config or
- doing a manual SQL fix) to migrate.
+- **Embedding mismatch after a model change**: startup logs a warning
+ when stored `(provider, model, dim)` triples differ from config.
+ Hybrid search ignores stale rows until they are re-embedded. Start
+ the server normally, then run `ai-memory embed --reembed` (or rely
+ on scheduled embedding backfill if enabled).
- **Container restart loop**: check
`docker logs ai-memory` - the `ai-memory starting` line at the top
reports the resolved config; a missing required env var (e.g.