AgentDB

May 6, 2026 Β· View on GitHub

npm version npm downloads License TypeScript

πŸ•ΈοΈ RuVector Engine 🧠 SONA Self-Learning πŸ”Œ MCP Compatible ⭐ Star on GitHub

AgentDB

Vector memory that gets smarter every time your agent uses it.

A single-file cognitive container β€” vectors, indexes, learning state, and a cryptographic audit trail in one .rvf. Self-learning search improves up to 36% from feedback alone, with no manual tuning. Runs in Node, the browser, edge runtimes, and offline.

Why AgentDB?

Most vector databases store embeddings and call it done. AgentDB watches which results your agent actually used, learns from that signal, and ranks the next query better. The bandit underneath also picks the right RL algorithm, the right compression tier, and the right pattern weighting on its own β€” so the database itself gets sharper while you focus on the agent.

The name: a database that thinks like an agent β€” episodic memory, skill library, causal reasoning, and a learning loop, all in one file. Built by rUv on the ruvector Rust engine.

What AgentDB Does

Self-Learning Vector Memory

Agent ──► AgentDB (.rvf) ──► HNSW search ──► top-k results
   β”‚                                              β”‚
   β–Ό                                              β–Ό
recordFeedback(id, reward)  ◄──  agent uses some, ignores rest
   β”‚
   β–Ό
Bandit re-tunes ranking / RL choice / compression  ──► next query is smarter

3 lines to self-learning search:

const backend = await SelfLearningRvfBackend.create({ learning: true, storagePath: "./my.rvf" });
const results = await backend.searchAsync(query, 10);   // search
backend.recordFeedback(results[0].id, 0.9);             // learn β€” next search is smarter

Quick Start

There are three ways to use AgentDB depending on what you're building. Pick whichever matches your stack:

npm libraryCLIMCP server
What you getTypeScript / JS API for any Node appagentdb binary, scriptable from any shell41 tools callable from Claude Code, Cursor, Cline, etc.
Installnpm i agentdbnpx agentdb … (no install)claude mcp add agentdb -- npx agentdb mcp start
Best forEmbedding the engine in your own codeQuick experiments, CI scripts, ad-hoc memoryPlugging memory + learning into an LLM agent

Path A β€” npm library

npm install agentdb
import { SelfLearningRvfBackend } from 'agentdb';

const db = await SelfLearningRvfBackend.create({
  learning: true,
  storagePath: './memory.rvf',
});

await db.insertAsync('doc1', new Float32Array(384), { text: 'Hello world' });
const hits = await db.searchAsync(queryEmbedding, 5);
db.recordFeedback(hits[0].id, 1.0);  // it was useful β€” db gets smarter

Path B β€” CLI in 10 seconds

# Try it without installing
npx agentdb init my-memory.rvf
npx agentdb add my-memory.rvf "vector memory that learns"
npx agentdb search my-memory.rvf "self-improving search" --top-k 5

Path C β€” MCP server (Claude Code, Cursor, etc.)

claude mcp add agentdb -- npx agentdb@latest mcp start

That registers 41 MCP tools β€” agentdb_pattern_store, agentdb_pattern_search, agentdb_hierarchical_store, agentdb_causal_edge, agentdb_skill_library, agentdb_reflexion, etc. They call the same engine the npm library does, just over Claude's tool-calling surface.


What You Get

CapabilityDescription
🧠 Self-Learning SearchUp to +36% search quality from feedback alone β€” Thompson Sampling bandit re-tunes ranking, RL choice, and compression tier with zero manual config
🐝 Cognitive Memory6 human-inspired patterns β€” episodic replay (Reflexion), skill library, causal reasoning, hierarchical context, semantic clustering, working memory
πŸ€– 9 RL AlgorithmsQ-Learning, SARSA, DQN, PPO, Actor-Critic, Policy Gradient, Decision Transformer, MCTS, Model-Based RL β€” bandit picks the right one per task
⚑ 150Γ— faster than SQLiteRuVector Rust engine via NAPI bindings; HNSW vector search; sub-millisecond reads on 100k+ vectors
πŸ” Hybrid SearchBM25 keyword + dense vector fused with Reciprocal Rank Fusion β€” exact terms and semantic intent in one query
πŸ•ΈοΈ Graph IntelligenceCypher queries, causal edges, GNN 8-head attention (+12.4% recall), hyperedges for n-ary relationships
πŸ’Ύ Single-file StorageEverything (vectors, indexes, learning state, audit log) in one .rvf "Cognitive Container" β€” no servers, no API keys, no monthly bills
🎯 Quantization4-32Γ— memory reduction with PQ8 / PQ4 / binary quantization; minimal recall loss; runs on commodity hardware
πŸ”Œ 41 MCP ToolsFirst-class Claude Code / Cursor / Cline integration β€” pattern store, search, skill library, reflexion, causal edges, hierarchical recall, delete
🌐 Runs AnywhereNode, browser (WASM), edge runtimes, fully offline β€” same API, same .rvf file
πŸ›‘οΈ Enterprise SecurityJWT auth, API key rotation, Argon2id hashing, SOC2 / GDPR audit trails, cryptographic witness chain
πŸ”— agentic-flow IntegrationDrop-in for agentic-flow β€” backs ReasoningBank, MemoryController, NightlyLearner, and 30+ agents

🧠 Self-Learning Loop

Most retrieval systems are read-only. AgentDB closes the loop:

search ──► top-k ──► agent picks the useful ones ──► recordFeedback()
                                                            β”‚
                                                            β–Ό
                                              Thompson Sampling bandit
                                                            β”‚
                                                            β–Ό
                       re-weights ranking Β· re-picks RL algorithm Β· re-tunes compression
                                                            β”‚
                                                            β–Ό
                                                   next search is sharper

The bandit isn't a gimmick β€” it's used at four decision points:

  1. Pattern ranking β€” which historical pattern matches this new query best?
  2. RL algorithm selection β€” Q-Learning for tabular tasks, PPO for continuous control, MCTS for planning, etc.
  3. Compression tier β€” full precision when accuracy matters, PQ4 when memory does.
  4. Skill composition — chain skill A→B→C or skill A→D→E?

Each decision logs reward over time. Bad arms decay fast. Good arms stick.


⚑ Performance

MetricAgentDBBaselineSource
Vector search (100k vectors)<1 ms~150 ms (SQLite + cosine loop)benchmarks/hnsw/
HNSW query (1M vectors)2–5 ms~100 ms (brute force)benchmarks/vector-search/
Bulk insert (10k vectors)<100 ms~12 s (sql.js)benchmarks/database/
Memory footprint (1M Γ— 384d)~96 MB (PQ8)~1.5 GB (raw f32)benchmarks/quantization/
Self-learning quality lift+36%n/abenchmarks/ruvector-performance.test.ts
GNN attention recall+12.4%baseline HNSWbenchmarks/attention-performance.ts

Run them yourself: npm run bench from this repo.


πŸ”Œ MCP Integration

41 tools across six families, all callable from Claude Code, Cursor, Cline, or any MCP-compatible client:

Pattern Store / Search (8 tools)
ToolPurpose
agentdb_pattern_storeStore a successful pattern with embedding + metadata
agentdb_pattern_searchSemantic search for similar past patterns
agentdb_pattern_statsRetrieval stats, cache hits, hit-rate trends
agentdb_pattern_deleteRemove a pattern by id
agentdb_batch_insertBulk insert many patterns at once
agentdb_batch_searchParallel multi-query search
agentdb_exportDump patterns to JSON / CSV
agentdb_importLoad patterns from JSON / CSV
Hierarchical / Causal Memory (10 tools)
ToolPurpose
agentdb_hierarchical_storeTier-aware memory store (working / short / long)
agentdb_hierarchical_recallTier-filtered retrieval
agentdb_hierarchical_deleteRemove hierarchical entry by key
agentdb_causal_edgeAdd a causal relationship between memories
agentdb_causal_edge_deleteRemove a causal edge by id
agentdb_causal_node_deleteCascade-delete a node + incident edges
agentdb_edges_by_endpointsBulk-delete edges by (from, to, label)
agentdb_causal_queryCypher-like graph queries
agentdb_causal_explainExplain why two memories are connected
agentdb_attestation_logCryptographic audit trail
Reflexion + Skill Library (12 tools)
ToolPurpose
agentdb_reflexion_storeStore an episode (task + outcome + critique)
agentdb_reflexion_recallRetrieve relevant past episodes
agentdb_reflexion_deleteRemove an episode
agentdb_reflexion_rebuildRe-hydrate vector index from durable SQL
agentdb_skill_createCreate a reusable skill from a pattern
agentdb_skill_composeChain skills A→B→C with bandit-picked composition
agentdb_skill_searchFind skills by intent embedding
agentdb_critique_summarySummarize lessons from past failures
agentdb_success_strategiesSurface what worked across past episodes
agentdb_task_statsPer-task win-rate, latency, reward trends
agentdb_pruneTTL + quality-based episode pruning
agentdb_warm_cachePre-populate query cache for a session
Learning + Routing (11 tools)
ToolPurpose
agentdb_learning_routeRoute a task to the right RL algorithm
agentdb_learning_trainTrain a specific RL agent on episodes
agentdb_learning_predictGet an action prediction for a state
agentdb_bandit_updateUpdate bandit reward for an arm
agentdb_bandit_pickSample the best arm under Thompson Sampling
agentdb_consolidateRun NightlyLearner consolidation pipeline
agentdb_composeCombine memory patterns into a strategy
agentdb_synthesizeBuild a context window from related memories
agentdb_explain_recallFeature-attributed retrieval results
agentdb_diversity_rankMMR-rerank for diverse top-k
agentdb_metadata_filterFiltered semantic search

πŸ”— Used By

AgentDB powers the memory + learning layer in:

ProjectWhat it uses AgentDB for
agentic-flowReasoningBank backend, ReflexionMemory, NightlyLearner consolidation, 30+ agent memory namespaces
rufloPlugin marketplace memory, agent federation audit log, hierarchical recall for /adr-index, swarm coordination patterns
@ruvectorReference downstream for the Rust engine β€” every release is verified against AgentDB's test suite

If you ship something on top of AgentDB, open an issue and we'll add you.


🐳 Docker / Edge / Browser

AgentDB compiles to four targets from one source:

TargetWhatWhen
Node nativeNAPI bindings (Linux, macOS, Windows; x64 + arm64)Backend services, CLI, MCP server
Node WASM fallbacksql.js + WASM engineRestricted hosts that can't run NAPI
BrowserPure WASM bundleOffline-first apps, edge functions, IDE extensions
Dockerdocker-compose.yml in docker/Local dev, CI, prod deploy
# Browser
import { createBrowserDb } from 'agentdb/browser';

# Docker
docker compose -f docker/docker-compose.yml up

Documentation

DocWhen to read it
Full README (deep)Every feature, every API, every option β€” the complete reference (2,900+ lines)
PUBLISHING.mdnpm publish flow, dist-tag policy, release verification
ADR-071WASM integration design
ADR-072RuVector advanced-feature integration
ExamplesEnd-to-end runnable scripts β€” RAG chatbot, code-review agent, RL training, edge deploy
BenchmarksReproducible perf harness β€” HNSW, attention, quantization, RL, end-to-end

Repository

πŸ“¦ npmagentdb
🌐 Sourcehttps://github.com/ruvnet/agentdb
πŸ› Issueshttps://github.com/ruvnet/agentdb/issues
🎨 Marketing siteui/ (Vite + React + shadcn/ui)
🧬 Engine@ruvector (Rust + NAPI)
πŸ”— Reference consumeragentic-flow (uses this as a git submodule at packages/agentdb/)

Support

ResourceLink
Documentationdocs/README-full.md
Issues & BugsGitHub Issues
Enterpriseruv.io
CommunityAgentics Foundation Discord
Engineruvector
Powered byCognitum.one

License

MIT OR Apache-2.0 β€” RuvNet