Open-Source Context Database for AI Agents
Filesystem paradigm for unified memory, resources, and skills
agent37.club
Context is the bottleneck, not the model. A smarter context layer makes any LLM more capable.
Each pillar addresses one of the five pain points. Let's dig into each.
viking:// |-- resources/ # project docs, repos, web | |-- github.com/ | | |-- volcengine/OpenViking/ | | |-- README.md | | |-- docs/ | | |-- examples/ | |-- uploads/ |-- user/ # preferences, habits |-- agent/ # skills, instructions |-- skills/ |-- memories/
# Add a GitHub repo as a resource ov add-resource https://github.com/volcengine/OpenViking # List contents of a directory ov ls viking://resources/ # View tree structure (depth-limited) ov tree viking://resources/volcengine -L 2 # Semantic search across all context ov find "how does authentication work" # Grep within a specific subtree ov grep "openviking" --uri viking://resources/volcengine/OpenViking/docs # Check server status ov status
The CLI maps directly to the Python SDK. Every ov command has a corresponding client.method() call.
| Tier | Size | Content | When Loaded |
|---|---|---|---|
| L0 | ~100 tokens | One-sentence abstract | Always (index browsing) |
| L1 | ~2,000 tokens | Core info, usage, key concepts | When directory is relevant |
| L2 | Full size | Complete original content | Only when explicitly needed |
When you add a resource, OpenViking's VLM automatically generates L0 and L1 summaries. The L2 data is stored as-is. No manual summarization needed.
# Get each tier programmatically l0 = client.abstract(uri) # L0 l1 = client.overview(uri) # L1 l2 = client.read(uri) # L2
Consider an agent with access to 50 documents averaging 10,000 tokens each.
Load all 50 docs into context. Expensive, slow, often exceeds context window.
25,000 tokens total -- 95% reduction
OpenClaw evaluation: OpenViking with memory used 2.1M tokens vs. LanceDB RAG at 51.6M tokens. That is a 96% reduction in token consumption.
Parse the query into multiple retrieval conditions. "How to deploy with K8s" becomes conditions for deployment, Kubernetes, infrastructure.
Match conditions against L0 abstracts to find high-relevance directories (not individual chunks).
Within matched directories, search L1 overviews to narrow to specific files/sections.
If a match is itself a directory, recurse into its subdirectories. Continues until leaf nodes are reached.
Aggregate scored results across all branches. Return ranked context with full URI paths.
Think of it as: RAG is grep across a flat text dump. OpenViking is find + cd + cat across a structured tree.
When the agent retrieves context, OpenViking records the full trajectory:
# Retrieval trajectory for: # "How to configure K8s deployment" Query decomposition: cond_1: kubernetes deployment config cond_2: helm chart setup Directory scan: viking://resources/ -> score: 0.82 docs/deployment/ -> score: 0.94 k8s-guide.md -> score: 0.97 examples/k8s-helm/ -> score: 0.91 Selected: 2 resources, 4200 tokens
At the end of each session, OpenViking's memory extraction mechanism processes the conversation to extract:
Extracted knowledge is stored under viking://user/ and viking://agent/ and surfaced in future sessions via L0/L1 retrieval.
This is not a simple chat history store. The VLM processes raw session data into distilled, actionable knowledge -- extracting patterns from noise. Over time, the agent's context database becomes a growing knowledge base.
Session content is automatically compressed. Tool calls are extracted for reuse. Resource references are deduplicated. The memory grows in knowledge, not in tokens.
import openviking as ov # Initialize (embedded mode -- no server needed) client = ov.OpenViking(path="./data") # Or connect to a running server: # client = ov.SyncHTTPClient(url="http://localhost:1933") client.initialize() # Add a resource (URL, file, or directory) res = client.add_resource(path="https://github.com/volcengine/OpenViking") root_uri = res["root_uri"] # Browse the indexed structure client.ls(root_uri) client.glob(pattern="**/*.md", uri=root_uri) # Wait for L0/L1 processing to complete client.wait_processed() # Access tiered summaries abstract = client.abstract(root_uri) # L0 overview = client.overview(root_uri) # L1 content = client.read(uri) # L2 # Semantic search results = client.find("how does auth work", target_uri=root_uri) for r in results.resources: print(f" {r.uri} (score: {r.score:.4f})")
| Mode | Use Case |
|---|---|
| Embedded | Single-process, local dev. ov.OpenViking(path=...) |
| Client-Server | Multi-agent, production. openviking-server on port 1933 |
# Production deployment helm install openviking \ ./deploy/helm/openviking \ --set vlm.provider=openai \ --set vlm.model=gpt-4o \ --set embedding.provider=openai
Server mode supports workspace isolation. Each tenant gets a separate viking:// filesystem. See examples/multi_tenant/.
| Provider | VLM Models | Embeddings |
|---|---|---|
| Volcengine | doubao-seed-2.0-pro | doubao-embedding-vision |
| OpenAI | gpt-4o, gpt-4-vision | text-embedding-3-large |
| LiteLLM | claude-3.5, deepseek, gemini | -- |
| Jina | -- | jina-embeddings-v3 |
| Ollama | llama3.1, mistral, etc. | -- |
# ov.conf -- LiteLLM with Claude { "vlm": { "provider": "litellm", "model": "claude-3-5-sonnet", "api_key": "sk-..." }, "embedding": { "dense": { "provider": "openai", "model": "text-embedding-3-large", "dimension": 3072 } } }
| Integration | Description |
|---|---|
| claude-memory-plugin | Persistent memory for Claude |
| opencode-memory-plugin | Memory for OpenCode agents |
| openclaw-plugin | Context for OpenClaw framework |
| mcp-query | Model Context Protocol server |
| VikingBot | Built-in chat interface |
# Install with bot support pip install "openviking[bot]" # Start server with built-in bot openviking-server --with-bot # Chat with your context ov chat
The mcp-query example exposes OpenViking as an MCP tool server -- any MCP-compatible agent can use it for context retrieval.
Key takeaway: +43% task completion over baseline, 96% fewer tokens than RAG. Memory mode trades ~1% accuracy for an additional 50% token savings.
volcengine/OpenViking |-- openviking/ # Python core package |-- openviking_cli/ # Python CLI wrapper |-- crates/ov_cli/ # Rust CLI (fast) |-- src/ # Core implementation |-- deploy/helm/ # K8s Helm charts |-- examples/ # Integration demos | |-- claude-memory-plugin/ | |-- mcp-query/ | |-- openclaw-plugin/ | |-- multi_tenant/ | |-- server_client/ | |-- skills/ |-- tests/ # Test suite
| Language | Component |
|---|---|
| Python | Core server, SDK, VLM integration |
| Rust | CLI tool (performance-critical) |
| Go | AGFS filesystem components |
| C++ | Low-level storage/indexing |
Requires Python 3.10+, Go 1.22+, GCC 9+ or Clang 11+. Linux, macOS, or Windows.
OpenViking is not a replacement for RAG or long context. It is a structured layer on top that organizes context hierarchically, loads it progressively, and learns across sessions.
| Feature | Vector DB (RAG) | Long Context | OpenViking |
|---|---|---|---|
| Structure | Flat chunks | Linear prompt | Hierarchical filesystem |
| Retrieval | Top-K similarity | Full window | Recursive directory drill-down |
| Token Efficiency | Medium (chunks) | Low (load everything) | High (L0/L1/L2 tiers) |
| Cross-Session Memory | Manual | None | Automatic extraction |
| Observability | Score only | N/A | Full trajectory |
| Agent Familiarity | Custom API | Prompt engineering | ls, find, tree, glob |
| Multi-Tenancy | Index per tenant | N/A | Workspace isolation |
// ~/.openviking/ov.conf { "storage": { "workspace": "/data/openviking" }, "log": { "level": "INFO", "output": "stdout" }, "embedding": { "dense": { "api_base": "https://api.openai.com/v1", "api_key": "sk-...", "provider": "openai", "dimension": 3072, "model": "text-embedding-3-large" }, "max_concurrent": 10 }, "vlm": { "api_base": "https://api.openai.com/v1", "api_key": "sk-...", "provider": "openai", "model": "gpt-4o", "max_concurrent": 100 } }
The VLM is not optional -- it powers L0/L1 summary generation, memory extraction, and intent analysis during retrieval. Choose a capable model.
# 1. Start Ollama with a model ollama pull llama3.1 ollama serve # 2. Configure OpenViking # ~/.openviking/ov.conf { "vlm": { "provider": "litellm", "model": "ollama/llama3.1", "api_base": "http://localhost:11434" }, "embedding": { "dense": { "provider": "jina", "model": "jina-embeddings-v3", "api_key": "jina_...", "dimension": 1024 } } } # 3. Launch openviking-server
LiteLLM automatically routes based on model name prefix:
| Prefix | Routes To |
|---|---|
| claude-* | Anthropic |
| deepseek-* | DeepSeek |
| gemini-* | |
| ollama/* | Local Ollama |
| hosted_vllm/* | vLLM server |
OpenViking shines for complex agents that work across many documents, learn over time, and need to manage token budgets intelligently.
Context is the bottleneck. Structure is the solution.
pip install openviking
agent37.club