DEV Community

Arman
Arman

Posted on

I'm building CortexDB — an agent-native context database for AI agents

I'm building CortexDB — an agent-native context database for AI agents

Most modern RAG systems work like this:

  1. Split documents into chunks
  2. Generate embeddings
  3. Store them in a vector database
  4. Retrieve top-k similar chunks on query
  5. Send them to an LLM

It works for simple use cases. But as AI agents become more autonomous and complex, a clear problem appears:

Agents don’t just need similar text chunks.

They need bounded, permission-safe, evidence-aware, and verifiable context.

This is why I started building CortexDB.

GitHub: https://github.com/AubakirovArman/CortexDB

What is CortexDB?

CortexDB is a single-node, agent-native context database. Its main goal is to compile ContextPacks — structured, citation-rich, token-budgeted bundles of context for AI agents.

Instead of returning raw chunks, it returns a ready-to-use package that includes:

  • Source citations
  • Explanation of why each piece was selected
  • Token usage information
  • Anomaly and conflict detection
  • Permission and scope awareness

Key Features

  • ContextPack — structured output format with citations and token control
  • VERIFY FACT — deterministic fact verification (including numerical conflicts)
  • AQL — custom declarative query language designed for agents
  • Tool Registry + Typed Knowledge Graph
  • Durable single-node storage (WAL + MVCC)
  • Published SDKs for Python, TypeScript, and Rust

Example: ContextPack


json
{
  "token_budget_tokens": 4000,
  "estimated_tokens": 2500,
  "truncated": false,
  "citations_required": true,
  "cells": [...],
  "anomalies": [...]
}
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
motedb profile image
mote

ContextPacks with citations is the right instinct. We went through the same evolution with moteDB — raw vector retrieval is great until you need deterministic state queries alongside semantic search.

The citation piece is critical for trust. When the agent retrieves "the door was closed at 3pm" from memory, you need to know which sensor said that, not just that the LLM hallucinated it.

Curious how you handle the token budget vs. recall tradeoff in practice — does ContextPack size grow unbounded or do you have eviction?