AGENT INFRAAI AGENTOPEN SOURCE
cctx — Agent Context Store
One memory for every agent I run. SQLite full-text search under 100ms. No vector database.
SQLite FTS5 · Turso / libSQL · FastAPI · FastMCP · Claude Code Hooks · Railway + Docker
The Problem
Every agent session starts from zero. Claude Code forgets what Cursor learned; the API call has no idea what happened in the terminal an hour ago. The usual answer is a vector database, an embedding pipeline, and a re-index job — three more things to run before you get one useful retrieval. I wanted the boring version: a single store every agent writes to automatically, keyword retrieval that is fast enough to run on every turn, and nothing to babysit. cctx is that store. It is open source, MIT licensed, and it is the system of record I now run my own work against.
Stack
🗄️
SQLite FTS5
BM25 ranked full-text retrieval, <100ms, no vector DB or embeddings
☁️
Turso / libSQL
Cloud primary with a local embedded replica for fast reads
⚡
FastAPI
9 REST endpoints — capture, search, definitions, sessions
🔌
FastMCP
MCP tool layer so any agent can read and write memory
🪝
Claude Code Hooks
Auto-capture every turn — the corpus is complete by default
🚀
Railway + Docker
Deployed server; per-machine installer
How It Works
The execution path
Turn captured
↳ every agent turn
Hooks01
Fire a hook on every agent turn
Claude Code, Cursor, Messages API
Turso02
Write to the Turso primary
The embedded replica syncs
Indexed · FTS5
SQLite FTS503
Update the index in place
No re-index step
Agent queries
MCP · REST04
Call search or batch_search
BM2505
Rank the results
Top results in under 100ms
Context injected
.def files06
Check the definition files
Current project truth. History is evidence, .defs are authority.
Session start07
Inject context into the agent
At session start and at stage checkpoints
TriggerStepOutput
The design bet is that BM25 over well-captured context beats embeddings over poorly-captured context. Hooks auto-capture every turn — no paste, no prompt ritual — so the corpus is complete, and SQLite FTS5 returns ranked results in under 100 milliseconds. When I needed a month of work analyzed for a resume, I queried 12,148 of my own messages straight out of production. The store answered questions about itself.
Key Design Decisions
🚫
No Vector Database
FTS5 + BM25 over a complete corpus. No embedding pipeline, no re-index job, no second datastore to keep in sync.
🪝
Capture Is Automatic
Hooks write every turn. The memory is complete because nobody has to remember to save anything.
📜
History vs. Authority
Conversation history is evidence. Definition files hold current truth — ICP, pricing, pivots, the graveyard of rejected approaches.
🔌
One Store, Every Agent
Claude Code, Cursor, the Anthropic API, and Managed Agents all read and write the same memory through MCP and REST.
By The Numbers
← back to all systemsmatthew batterson · gtm engineer