v2.117.0 · a live view you can ask

AI memory and a knowledge graph in one SQLite file.

CortexDB is an open-source Go library for agent memory. One file holds vectors, full-text search, RAG documents, scoped memories and an RDF knowledge graph with SPARQL, inference and validation. It runs inside your program, works without an embedding model, and is MIT licensed.

$ go get github.com/liliang-cn/cortexdb/v2
The CortexDB live view, dark theme: the code graph of CortexDB itself, packages, files and types colored by node type, with package names drawn on the scene
serve_graph_3d on the code graph of CortexDB itself: 600 of its 3,835 symbols drawn, the rest one search or expansion away.

At a glance

What
Embedded AI memory + knowledge graph
Language
Go, no CGO · clients for Rust, Python, Node
Storage
One SQLite file, or PostgreSQL + pgvector
Models
Optional — lexical mode needs no API key
Graph
RDF 1.2, SPARQL, OWL 2 RL, SHACL, Cypher
Agents
80+ MCP tools · Claude Code & Codex plugin
License
MIT
Latest
v2.117.0 ·

Features

Everything an agent needs to remember, in the file next to your code.

No service to deploy and no second database to keep in sync: SQLite by default, PostgreSQL with pgvector when you outgrow one file.

Agent memory

Remember, Recall, Reflect and Consolidate over user, session and global scopes. Recall returns a paste-ready context pack with sources, and relational answers come back as graph facts — Alice —uses→ Apollo — read from edges.

Retrieval that walks the graph

Vector, lexical, hybrid and graph lanes fused by rank, plus Personalized PageRank (HippoRAG 2) for questions whose answer is two hops away. auto picks the walk only when the question names a specific entity.

A real knowledge graph

RDF 1.2 triple terms, SPARQL 1.1 and 1.2, read-only Cypher, RDFS and an OWL 2 RL subset, SHACL validation and SHACL-AF rules. Every inferred triple can explain itself; contradictions are reported, never guessed away.

A change feed

Every committed write lands in change_log in the same transaction — commit order, exactly once, nothing from a rollback. It keeps inferences current automatically and is what a sync or trigger builds on.

Built for agents

80+ tools with the same names in-process and over MCP. A plugin gives Claude Code and Codex one shared brain with /remember, /recall and an auto-recall hook; a gRPC server shares it across machines.

No model required

CortexDB never imports an LLM SDK. Without an embedder it searches lexically — Chinese questions asked as whole sentences included — and still builds the entity graph. Add any OpenAI-compatible embeddings endpoint for vectors.

Ontology and governed actions

Typed objects, links and interfaces with primary keys and cardinality, an object-set algebra, action types with an audit trail, and a breaking-change schema diff — Palantir-style, in the same file.

Vectors, compact

HNSW, IVF and flat indexes, scalar and product quantization, and 1-bit binary codes rescored exactly: recall@10 0.979–0.996 on real 768-d embeddings at 1/32 of the memory.

Answers that say how they know

Records carry their source, chunk, producer and a grade — verified, asserted, refused. An Authorize callback gates every retrieval candidate, so access control holds at the retrieval layer.

Get started

Three ways in.

Embed the library, give your coding agent a memory, or run one server many clients share.

01In a Go program

Open a file, remember, recall. No embedder needed.

main.go
db, _ := cortexdb.Open(cortexdb.DefaultConfig("brain.db"))
defer db.Close()
brain := db.KnowledgeMemory()

brain.Remember(ctx, cortexdb.KnowledgeMemoryRememberRequest{
    Content: "Alice prefers tabs.", Scope: "user",
})
rec, _ := brain.Recall(ctx, cortexdb.KnowledgeMemoryRecallRequest{
    Query: "what does Alice prefer?",
})
fmt.Println(rec.ContextPack.Text) // with sources

02In Claude Code or Codex

One global brain, slash commands and auto-recall. No API key.

plugin
# Claude Code
/plugin marketplace add liliang-cn/cortexdb
/plugin install cortexdb@cortexdb

# Codex
codex plugin marketplace add liliang-cn/cortexdb
codex plugin add cortexdb@cortexdb

# then, in any session
/remember Our staging DB is on port 45432
/recall staging database

03From any language

Run the gRPC server once; point clients and agents at it.

shell
go install github.com/liliang-cn/cortexdb/v2/cmd/cortexdb-grpc@latest

# typed clients
cargo add cortexdb-client
pip install cortexdb-client
npm install cortexdb-client

# share one brain between machines
export CORTEXDB_REMOTE=host:port

Benchmarks

Multi-hop recall up 15 points, with no embedding model.

Standard retrieval benchmarks run through the same public API an application calls — SaveKnowledge then SearchKnowledge — with cortexdb-bench. No embedder; auto is the default mode.

Recall@5 on the full question sets (LongMemEval: a seeded 100-question sample). CortexDB v2.115.0 on SQLite, Apple M2 Pro.
BenchmarkKindLexicalAutoAuto vs lexicalp95
2WikiMultiHopQAmulti-hop0.6570.80721 ms
MuSiQuemulti-hop0.4570.54228 ms
LoCoMoconversation0.4930.4958 ms
LongMemEvalconversation0.8610.86215 ms

The multi-hop gain comes from a Personalized PageRank walk over the entity graph SaveKnowledge builds; on single-hop conversation memory auto holds lexical's recall, because an entity most passages mention (a conversation's speaker) is not used to start the walk. Datasets are pinned by sha256; reproduce with go run ./cmd/cortexdb-bench.

0.979–0.996recall@10 of 1-bit binary codes with exact rescoring, at 1/32 of the memory
0 wronganswers across 3,897 openCypher TCK scenarios — what Cypher cannot do, it refuses
W3C suitesin-scope RDF 1.2 and SPARQL 1.2 tests pass on SQLite and PostgreSQL
Exactly onceevery committed write in the change feed, in commit order; nothing from a rollback

See it

A brain you can look inside.

CortexDB is inspectable by design. serve_graph_3d serves a live view from inside the MCP server handling the calls, so the graph lights up as agents touch it. Find any node across the whole store, ask a question, run read-only Cypher, and expand node by node. graph_schema reports the schema the data actually has, and every inferred fact can be traced back to the facts it came from.

  • Three themes, each light and dark, following the system by default
  • Works on a phone: the inspector becomes a bottom sheet
  • Every view is a link: ?focus=, ?ask=, ?cypher=, ?theme=
  • One file to back up, copy, diff or open with sqlite3
  • Explanations for every inference, reports for every contradiction
The live view in the Ember light theme, focused on one package, with its files labelled and the inspector open
The live view on a phone: the focused package at the top, the inspector as a bottom sheet
Ember light on a desktop, Space dark on a phone.

Fit

Embedded, inspectable, local-first.

A good fit when

  • an agent needs memory and a knowledge graph without another service to run
  • you want retrieval that works offline, with no API key
  • answers must cite where they came from and how sure they are
  • several agents or machines should share one brain

Look elsewhere when

  • you need a distributed vector database sharded across a cluster
  • you need a full enterprise RDF triple store with complete SPARQL 1.1 and OWL DL reasoning
  • billions of vectors must be served at low latency to many tenants

FAQ

Questions, answered directly.

What is CortexDB?

CortexDB is an open-source Go library that stores an AI agent's memory and knowledge in one SQLite file: vectors, full-text search, RAG documents, scoped memories, and an RDF knowledge graph you can query with SPARQL or read-only Cypher. It runs inside your program; there is no server to operate. It is MIT licensed.

Does CortexDB need an embedding model or an LLM?

No. CortexDB never imports an LLM SDK. Without an embedder it uses lexical retrieval (FTS5, including Chinese and Japanese text) and still builds an entity graph that graph-walking retrieval uses. Plugging in any OpenAI-compatible embeddings endpoint, such as Ollama, adds vector and hybrid search.

How is CortexDB different from a vector database?

A vector database stores embeddings and answers nearest-neighbour queries. CortexDB is an embedded library that also keeps agent memory with scopes, documents for RAG, and a knowledge graph with inference and validation, all in one file next to your code. It is not a distributed vector database and not an enterprise RDF server.

Can I use CortexDB from languages other than Go?

Yes. The cortexdb-grpc server exposes the same brain over gRPC, with typed clients for Rust (cargo add cortexdb-client), Python (pip install cortexdb-client) and Node.js (npm install cortexdb-client). Agents can also use it through its MCP server.

Does CortexDB work with Claude Code and Codex?

Yes. It ships as a plugin for both. In Claude Code run /plugin marketplace add liliang-cn/cortexdb, then /plugin install cortexdb@cortexdb. The plugin runs in lexical mode with no API key and keeps one global brain at ~/.cortexdb/cortexdb.db; point several machines at one cortexdb-grpc server to share it.

Which databases can CortexDB run on?

SQLite by default, through the pure-Go modernc.org/sqlite driver, so there is no CGO. A postgres:// connection string moves the same brain to PostgreSQL with pgvector; vectors, hybrid search, memory and the RDF graph behave the same on both.

What graph queries does CortexDB support?

SPARQL 1.1 (a documented practical subset) with SPARQL 1.2 triple terms, read-only Cypher over the property graph, RDFS and an OWL 2 RL subset kept current automatically as facts change, SHACL validation and SHACL-AF triple rules. The in-scope W3C RDF 1.2 and SPARQL 1.2 test suites pass on SQLite and PostgreSQL.

How good is CortexDB's retrieval without an embedder?

Measured through the public API with cortexdb-bench, no embedder, recall@5 in the default auto mode against plain lexical search: 2WikiMultiHopQA 0.807 vs 0.657, MuSiQue 0.542 vs 0.457, LoCoMo 0.495 vs 0.493, LongMemEval 0.862 vs 0.861, with p95 latency under 30 ms. The multi-hop gains come from a Personalized PageRank walk over the entity graph.

Give your agent a memory today.

Open source under MIT. One command to add it to a Go module.