Give it a database brain instead — with chDB.
Auxten Wang · Technical Director @ ClickHouse · Creator of chDB
@auxten · auxten.com
Append lines to a text file — memory.md, CLAUDE.md, AGENTS.md — then paste the whole thing back into the prompt.
It works on day one. It does not survive contact with a real session.
It hit a constraint and found the fix that worked.
Same task. It reads the prompt — not yesterday's fix.
Repeats the failed plan. Burns tool calls on retries.
Four kinds of it — and recall is choosing the few that matter now.
Great for tiny state. No columnar scan, no vectors, no remote files.
Great in memory. Dies past RAM. Can't query files you never loaded.
Closest match — but fewer formats and no mature cloud path.
Similarity only. Can't filter + join + aggregate + audit in one query.
The ClickHouse engine, embedded in your Python process — SQLite-simple, built to scan millions of rows.
# pip install chdb
from chdb import session as chs
sess = chs.Session("./agent")
sess.query("SELECT count() FROM file('log.pq')")
Parquet, CSV, JSON, Arrow, ORC — read & write, no converters.
Query a DataFrame or Arrow table in place — no copy, no load.
Prefer DataFrames to raw SQL? chDB v4 speaks that too.
Memory the agent can filter, rank, and grow — not a prompt blob.
Filter, rank, and audit them with plain SQL.
Meaning and business rules in one query.
Same SQL from laptop to ClickHouse Cloud.
Rank by meaning, keep the active ones, pinned first.
how close two meanings are (0 = identical)
Need project / tags / task history? Add a WHERE or JOIN — same query.
SELECT content,
1 - cosineDistance(embedding, :q) AS meaning
FROM memory
WHERE is_deleted = 0 -- rules
ORDER BY pinned DESC, meaning DESC
LIMIT 8
Beliefs change. "Use Poetry" → "this repo standardizes on uv."
Every revision is a new immutable row with a version. Deletes are a soft flag, never a real delete.
(For history, skip ReplacingMergeTree — it converges to one state and folds the past away.)
CREATE TABLE memory
(
memory_id UUID,
content String,
embedding Array(Float32),
version UInt64,
is_deleted UInt8 DEFAULT 0,
created_at DateTime64(3) DEFAULT now64()
)
ENGINE = MergeTree
ORDER BY (memory_id, version);
-- NOW: latest version per memory, minus soft-deletes
SELECT * FROM (
SELECT * FROM memory ORDER BY memory_id, version DESC LIMIT 1 BY memory_id
) WHERE is_deleted = 0;
-- HISTORY: how this belief evolved
SELECT * FROM memory WHERE memory_id = :id ORDER BY version;
-- POINT-IN-TIME: what did the agent believe as of version t?
SELECT * FROM (
SELECT * FROM memory WHERE version <= :t
ORDER BY memory_id, version DESC LIMIT 1 BY memory_id
) WHERE is_deleted = 0;
All three are append-only by nature — the same shape as the memory model. One local engine serves them as a single query surface.
decisions, facts, prior solutions.
traces of what the agent did.
the full conversation log.
5–20 tool calls / turn. Put recall over the wire and jitter becomes think-time jitter — and tokens.
chDB session on a laptop or agent runtime
ClickHouse Cloud when memory is shared or large
# Day 1 — query local memory
sess.query("SELECT content FROM memory WHERE project = 'checkout'")
# Day 100 — repoint the same name at the cluster (SELECT unchanged)
sess.query("""CREATE OR REPLACE VIEW memory AS
SELECT * FROM remote('cloud:9440', db, memory)""")
The whole pattern — lifecycle, recall, local-first — packaged open-source on chDB.
Embeddings: Qwen/Qwen3-Embedding-0.6B — runs locally, nothing leaves the box.
github.com/auxten/clickmem
chDB is the only data-infrastructure launch partner for Lambda MicroVMs. Every isolated session carries its own private chDB — Firecracker isolation, suspend / resume, zero network round-trips.
Filter it, rank it, join it, version it, evaluate it.
Semantic meaning + business rules, in one SQL.
chDB now; ClickHouse when it's shared or large.
pip install chdb
github.com/chdb-io/chdb
github.com/auxten/clickmem
Docs: clickhouse.com/docs/chdb
Blog & slides: auxten.com