Skip to main content
Version: Next

SochDB Documentation

Welcome to the official SochDB documentation. SochDB is The LLM-Native Database β€” a high-performance embedded database designed specifically for AI applications.

Current Version: v0.4.4 (Core) | Python SDK v0.4.7 | Node.js SDK v0.5.1 | Go SDK v0.4.3


What is SochDB?​

SochDB is a single database that replaces your vector DB + relational DB + prompt packer stack. Store structured data, embeddings, and conversation history togetherβ€”then ask SochDB to assemble token-optimized context for your LLM.

Comparison​

Database + retrieval layer​

FeatureSochDBSQLite + vecPostgres + pgvectorChromaLanceDB
Embeddedβœ…βœ…βŒβœ…βœ…
Vector searchβœ… HNSW⚠️ (via extension)βœ… (HNSW / IVFFlat)βœ…βœ…
Full SQL (user-facing)βœ… SQL-92βœ…βœ…βŒβœ…
Hybrid search (vector + keyword)βœ…βš οΈ (DIY)⚠️ (DIY)⚠️ (limited)βœ…
Context builderβœ…βŒβŒβŒβŒ
Token budgetingβœ…βŒβŒβŒβŒ
Graph overlayβœ…βŒβŒβŒβŒ
ACID transactionsβœ…βœ…βœ…βš οΈ (limited)❌
Columnar storageβœ…βŒβŒβŒβœ…

Memory / agent-memory layer​

FeatureSochDBMem0LettaGraphiti
Primary focusDB + retrieval + contextMemory layerAgent framework + memoryTemporal knowledge-graph memory
Long-term memory primitivesβœ…βœ…βœ…βœ…
Token-aware context budgetingβœ…βŒβŒβŒ
Graph-based memoryβœ…βŒβŒβœ…
Built-in vector storeβœ…βŒ (BYO)❌ (BYO)❌ (BYO)
Built-in agent runtimeβŒβŒβœ…βŒ
Drop-in β€œmemory add-on” to existing appsβœ…βœ…βš οΈβœ…

Quick links: πŸ“š Documentation β€’ Quick Start β€’ Architecture β€’ TOON Format β€’ Benchmarks β€’ RFD


Why SochDB?​

❌ The Typical AI Agent Stack​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ YOUR APPLICATION β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚ β”‚ β”‚
β–Ό β–Ό β–Ό β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Postgres β”‚ β”‚ Pinecone β”‚ β”‚ Redis β”‚ β”‚ Custom Code β”‚
β”‚ (metadata) β”‚ β”‚ (vectors) β”‚ β”‚ (sessions) β”‚ β”‚ (context assembly) β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β€’ User data β”‚ β”‚ β€’ Embeddings β”‚ β”‚ β€’ Chat state β”‚ β”‚ β€’ Token counting β”‚
β”‚ β€’ Settings β”‚ β”‚ β€’ Similarity β”‚ β”‚ β€’ Cache β”‚ β”‚ β€’ Truncation logic β”‚
β”‚ β€’ History β”‚ β”‚ search β”‚ β”‚ β€’ Temp data β”‚ β”‚ β€’ Prompt packing β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β€’ Multi-source fusion β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚ β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 😰 You manage all of this: β”‚
β”‚ β€’ 4 different query languages β”‚
β”‚ β€’ 4 sets of credentials β”‚
β”‚ β€’ 4 failure modes β”‚
β”‚ β€’ No cross-system transactionsβ”‚
β”‚ β€’ Weeks of glue code β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βœ… With SochDB​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ YOUR APPLICATION β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SochDB β”‚
β”‚ β”‚
β”‚ SQL + Vectors + Context Builder β”‚
β”‚ β”‚
β”‚ β€’ One query language β”‚
β”‚ β€’ One connection β”‚
β”‚ β€’ ACID transactions β”‚
β”‚ β€’ Token budgeting built-in β”‚
β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 😎 What you actually ship: β”‚
β”‚ β€’ Single ~700KB embedded DB β”‚
β”‚ β€’ Zero external dependencies β”‚
β”‚ β€’ Works offline β”‚
β”‚ β€’ Deploys anywhere β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The Problem β†’ Solution​

ChallengeTraditional StackSochDB
Token wasteJSON/SQL bloat in promptsTOON format for dense output
RAG plumbingSeparate vector DB + glue codeBuilt-in HNSW with hybrid search
Context assemblyCustom packer per use caseOne query with token budget
I/O overheadMultiple DB round-tripsSingle columnar read
ConsistencyDistributed transaction headachesLocal ACID guarantees
DeploymentManage 4 servicesSingle binary, embed anywhere

Key Features​

🧠 Context Query Builder β€” Assemble system + user + history + retrieval under a token budget
πŸ” Hybrid Search β€” HNSW vectors + BM25 keywords with reciprocal rank fusion
πŸ•ΈοΈ Graph Overlay β€” Lightweight relationship tracking for agent memory
⚑ Embedded-First β€” ~700KB binary, no runtime dependencies, SQLite-style simplicity
πŸ”’ Full ACID β€” MVCC + WAL + Serializable Snapshot Isolation
πŸ“Š Columnar Storage β€” Read only the columns you need


Why SochDB exists​

Most "agent stacks" still glue together:

  • a KV store (sessions / state)
  • a vector DB (retrieval)
  • a prompt packer (context budgeting, truncation)
  • a relational DB (metadata)

…and then spend weeks maintaining brittle context assembly and token budgeting.

SochDB collapses that stack into one LLM‑native substrate: you store structured data + embeddings + history and ask the DB to produce a token‑efficient context payload.


What you can rely on today​

βœ… LLM + agent primitives​

  • TOON: compact, model-friendly output for context windows
  • Graph Overlay: lightweight agent-memory graph with BFS/DFS traversal and relationship tracking
  • ContextQuery builder: token budgets, deduplication, and multi-source fusion
  • Policy hooks: safety controls with pre-built policy templates and audit trails
  • Tool routing: multi-agent coordination with dynamic discovery and load balancing
  • Hybrid retrieval: vector + BM25 keyword with Reciprocal Rank Fusion (RRF)
  • Multi-vector documents: chunk-level aggregation (max / mean / first)
  • Vector search (HNSW): integrated into retrieval workflows

βœ… Database fundamentals​

  • SQL (SQL-92): SELECT / INSERT / UPDATE / DELETE / JOINs
    • AST-based query executor: unified SQL processing with dialect normalization
    • Multi-dialect compatibility: MySQL, PostgreSQL, SQLite
    • Idempotent DDL: CREATE TABLE IF NOT EXISTS, DROP TABLE IF EXISTS
  • ACID transactions with MVCC
  • WAL durability + group commit
  • Serializable Snapshot Isolation (SSI)
  • Columnar storage with projection pushdown (read only the columns you need)
  • Sync-first architecture: async runtime (tokio) is optional
    • ~500KB smaller binaries for embedded use cases
    • Follows SQLite-style design for maximum compatibility

βœ… Developer experience​

  • Rust client: sochdb
  • Python & Nodejs & Golang SDK with:
    • Embedded mode (FFI) for lowest latency
    • IPC mode (Unix sockets) for multi-process / service deployments
    • Namespace isolation for multi-tenant apps
    • Typed error taxonomy with remediation hints
  • Bulk vector operations for high-throughput ingestion

Known limits​

  • Single-node only (no replication / clustering yet)

SochDB in one picture​

ProblemTypical approachSochDB approach
Token wasteJSON/SQL payload bloatTOON: dense, table-like output
RAG plumbingExternal vector DB + glueBuilt-in HNSW + quantization
Context assemblymultiple reads + custom packerOne context query with a budget
I/O amplificationrow store reads all columnscolumnar + projection pushdown

Quick Install​

cargo add sochdb
use sochdb::Database;

fn main() -> anyhow::Result<()> {
let db = Database::open("./my_app_db")?;

db.with_transaction(|txn| {
txn.put(b"users/alice", br#"{"name": "Alice", "role": "admin"}"#)?;
Ok(())
})?;

if let Some(user) = db.get(b"users/alice")? {
println!("{}", String::from_utf8_lossy(&user));
}

Ok(())
}

β†’ Full Quick Start Guide


Documentation Sections​

πŸš€ Getting Started​

Step-by-step guides to get you up and running quickly.

πŸ“– Guides​

Task-oriented guides for specific use cases.

Language SDKs:

  • Rust SDK β€” Native Rust guide
  • Python SDK β€” Complete Python guide (v0.4.7)
  • Node.js SDK β€” TypeScript/JavaScript guide (v0.5.1)
  • Go SDK β€” Go client guide (v0.4.3)

Features:

AI Agent Safety & Memory:

πŸ’‘ Concepts​

Deep dives into SochDB's architecture and design.

πŸ“‹ API Reference​

Complete technical specifications.

πŸ› οΈ Server Reference​

Deep technical documentation for SochDB servers and tools.

🍳 Cookbook​

Recipes for common tasks.


I want to...Go to...
Get started in 5 minutesQuick Start
Use Namespace & CollectionsPython SDK
Use Priority QueuesPython SDK
Use Memory SystemNode.js SDK
Use SQL queriesSQL Guide
Use the Rust SDKRust Guide
Use the Python SDKPython Guide
Use the Node.js SDKNode.js Guide
Use the Go SDKGo Guide
Add vector searchVector Search
Integrate with Claude (MCP)MCP Integration
Enforce agent safety policiesPolicy Hooks
Route tools across agentsTool Routing
Model agent memory relationshipsGraph Overlay
Build token-aware contextContext Query
Understand the architectureArchitecture
See the SQL API referenceSQL API