Inspiration

Everyone building an "agentic memory" project bolts a vector store onto an agent and calls it done. But a vector store can only tell you "these five things are similar" — it can't tell you which one is still true, when it stopped being true, or why the agent believes it. Real memory is transactional, temporal, and self-correcting. That's a database problem, not an embeddings problem — and CockroachDB is exactly the kind of database built to solve it. Anamnesis is what agent memory looks like when you take that seriously.

What it does

Anamnesis stores an agent's memory as structured, temporal, transactional data in CockroachDB, not a flat pile of embeddings:

  • Episodic + semantic memory — raw conversation events and consolidated beliefs are stored separately, each with vector embeddings for recall.
  • Time-travel over beliefs — every belief carries valid_from/valid_to validity intervals, so the agent can answer not just "what do you believe now" but "what did you believe last week."
  • Contradiction detection & self-correction — when a new statement contradicts an existing belief (vector similarity + LLM judgment), the old belief is superseded, not silently overwritten, with a full superseded_by audit chain.
  • Belief provenance — "why do you believe this?" — for any belief, the agent reconstructs the exact conversation turn it was formed from, its supersede lineage, and its full audit history. A similarity score is not a reason; this answers the trust question a vector store structurally cannot.
  • Consolidation & forgetting — a scheduled job folds low-salience episodic chatter into durable semantic beliefs and decays what's no longer relevant.
  • Full auditability & survivability — every write (episode, belief, supersede, consolidation, decay, retry) is logged in the same CockroachDB SERIALIZABLE transaction as the change it records, and writes survive both contention and a lost/killed connection mid-write via automatic retry of the whole transaction, not just the commit.
  • Self-aware infrastructure — a ccloud CLI-driven sub-agent periodically inspects the health of its own CockroachDB cluster and writes what it finds back into its own memory.

How we built it

The core is a Python library (anamnesis/) built directly on CockroachDB: SQLAlchemy models for episodic/semantic/audit tables, CREATE VECTOR INDEX for ANN recall, and a retry-guaranteed transaction primitive (run_in_transaction) that redoes an entire unit of work — reads and writes — from scratch on a serialization conflict or dropped connection, per CockroachDB's own client-retry contract.

On top of that: a FastAPI chat agent, a React (in-browser Babel, no build step) UI with a live memory panel showing the belief timeline and audit stream in real time, and a full AWS deployment — Lambda (chat API + scheduled consolidation + scheduled ops sub-agent), EventBridge schedules, S3 for reports, and Secrets Manager for credentials (never a plaintext env var). The whole stack is deployed and live right now, not just running locally.

For CockroachDB tools: Distributed Vector Indexing powers all recall and contradiction candidate search; the Managed MCP Server is wired for read-only introspection; a ccloud CLI sub-agent inspects its own cluster's health with a least-privilege RBAC service account; and the open-source CockroachDB Agent Skills repo caught two real bugs during development (see .claude-skills/README.md).

Challenges we ran into

  • Bedrock access got blocked account-wide on this AWS account (a new-account activity-history gate, confirmed with AWS Support). Rather than fake it, we built a genuinely real, free, local alternative (Ollama running Llama 3.2 + sentence-transformers) that powers real reasoning in the demo, while the Bedrock integration code itself is complete and ready to flip on the moment access clears.
  • A real concurrency bug: under simultaneous conflicting writers, the pre-read contradiction check could pass validation against a stale candidate. Fixed with a SELECT ... FOR UPDATE re-scan inside the write transaction, stress-tested with a concurrency harness.
  • A real network-partition finding: TCP keepalives were needed for the client to detect a silently-partitioned node in seconds instead of minutes — and even then, one write in twenty hit a bounded timeout, an honest finding about server-side lease-transfer recovery time, not swept under the rug.
  • CI silently broke for several commits when an unpinned linter picked up stricter default rules — caught during a deliberate pre-submission review, not by CI itself, and fixed by pinning the dependency.

Accomplishments that we're proud of

A quantified benchmark against a naive vector-store baseline across 50 real contradiction scenarios (not a small curated set) — Anamnesis answers "what do you believe now" correctly 24/50 vs a naive vector store's 6/50, time-travel 50/50 vs 44/50 — reported alongside an honest finding about cross-topic precision limits, not smoothed over. A real live node-kill demo against a genuine 3-node CockroachDB cluster: 30/30 writes survive a docker kill mid-run. Every claim in this project is backed by a real, reproducible run, not just code that looks right.

What we learned

That "agentic memory" is a genuinely different problem from a search index, and that the honest, rigorous path — measuring instead of asserting, disclosing limitations instead of hiding them, re-verifying instead of assuming — produces a stronger, more defensible project than chasing a bigger feature list.

What's next for Anamnesis

Multi-tenant scoping for consolidation, tuning the contradiction-similarity threshold per embedding model, and flipping on live Amazon Bedrock the moment account access clears.

Built With

Share this project:

Updates