README
ΒΆ
OKF Agent Memory
A Domain-Neutral, Git-Native Persistent Project Memory for AI Agents based on the Open Knowledge Format (OKF) v0.2.
π Overview
Conversations with AI agents reset when context windows close. Valuable architectural decisions, domain discoveries, and operational facts are lost unless stored persistently.
OKF Agent Memory provides a standardized, vendor-neutral memory layer that lives directly in your repository (knowledge/) as plain Markdown files with YAML frontmatter. It bridges the gap between unstructured ad-hoc markdown files (CLAUDE.md, AGENTS.md) and complex, black-box vector databases.
flowchart TD
L1["1. OKF v0.2 Specification<br/>(Normative Markdown & YAML Format)"]
L2["2. Agent Memory Convention<br/>(Behavioral Rules: Search, Review, Trust)"]
L3["3. Agent Skill<br/>(LLM Prompts & Operational Workflows)"]
L4["4. Tooling Layer: Go Library & CLI<br/>(Deterministic Parsing, Validation, Search, MCP)"]
L5["5. Project Knowledge Corpus<br/>(knowledge/ OKF Bundle)"]
L1 --> L2
L2 --> L3
L3 --> L4
L4 --> L5
β‘ Key Highlights
- Blazing Fast Performance (<300Β΅s Search, ~4ms Graph Validation): In-memory BM25 retrieval and bundle validation execute in microseconds without VM spin-up or network roundtrips.
- 100% Git-Native & Zero Vendor Lock-in: Everything is version-controlled plain text. Inspect, audit, and review your agent's memory using standard
git diffandgit log. No external database required. - Zero API Costs for Memory Retrieval: Local lexical BM25 indexing eliminates recurring vector embedding API costs and network roundtrips.
- Built on Google OKF v0.2: Uses the open standard format for agent knowledge with full support for provenance (
sources), trust tiers (generatedvs.verified), and lifecycle metadata (status,stale_after). - Solves Context Bloat & Memory Rot: Employs Progressive Disclosure (hierarchical
index.mdfiles and link graphs) so agents only load the exact concepts they need. - Search-Before-Write Principle: Mandates querying existing memory before authoring, preventing concept duplication and hallucinated divergence.
- Zero-Dependency Go Toolchain: Single binary with zero external dependencies, sub-5ms CLI startup time, and a built-in Model Context Protocol (MCP) server (
okf mcp). - Truly Domain-Neutral: Designed for Software Engineering, Coaching, Scientific Research, Literature Reviews, and Operations.
π Performance Benchmarks
Built in Go with zero external dependencies, okf is engineered for high-frequency agent tool calling loops:
| Benchmark Metric | Python / Vector DB Runtimes (Mem0, Letta) | Deno / Node.js Tooling | OKF Agent Memory (Go) |
|---|---|---|---|
| Concept Search Latency | 150ms β 800ms (Embedding API + Vector DB) | 40ms β 120ms | < 300 Β΅s (Microseconds, In-Memory BM25) |
| Full Corpus Parse & Graph Validation | 200ms β 1.5s | 80ms β 250ms | ~4.0 ms (50+ concepts, bidirectional graph) |
| Process Cold-Start Overhead | 250ms β 600ms (Python VM boot) | 80ms β 180ms (V8 / Deno boot) | < 4 ms (Compiled Single Binary) |
| Retrieval Cost per 1,000 Queries | ~$0.10 β $0.50 (Embedding tokens) | $0.00 | $0.00 (Zero API cost, fully local) |
| Memory Footprint (RSS) | ~120 MB β 350 MB | ~60 MB β 140 MB | < 15 MB |
[!TIP] Reproduce Locally with your own LLM: We provide an automated benchmark runner in pure Go to verify Time-To-First-Token (TTFT) speedups and -80% token reduction on your local hardware (LM Studio / Ollama with Gemma, Qwen, Llama). Run
make benchmarkor explore the Progressive Disclosure Benchmark Suite.
π Quickstart
1. Build the Tooling
Clone the repository and compile the standalone okf executable:
make build
This generates the standalone binary at bin/okf.
2. Basic CLI Commands
# Validate bundle conformance, graph connectivity, and description drift
./bin/okf validate knowledge --strict --drift
# Search concepts via in-memory BM25 scoring
./bin/okf search "architecture layers" knowledge
# Inspect a concept and its relationships (with --json support)
./bin/okf show architecture/layers knowledge --json
# Create a new concept with automated log.md and index.md bookkeeping
./bin/okf create decisions/auth-flow knowledge \
--type Decision \
--title "OAuth2 Authorization Flow" \
--desc "Standardized on PKCE for client authentication."
# Update an existing concept
./bin/okf update decisions/auth-flow knowledge \
--desc "Updated OAuth2 PKCE token refresh interval."
# Bootstrap full agent memory stack into any target project
./bin/okf bootstrap /path/to/project --name "My Project"
# Initialize only a bare OKF bundle in any directory
./bin/okf init my-project/knowledge
3. Bootstrapping Agent Memory in Any Project
Scaffold the complete OKF Agent Memory architecture into any new or existing repository with a single command:
# Bootstrap full memory stack into target project
./bin/okf bootstrap /path/to/my-project --name "My Service"
This automatically sets up:
knowledge/β OKF v0.2 compliant persistent memory bundle (index.md,log.md).agents/skills/okf-memory/β Embedded agent skill definition and capability guidesAGENTS.mdβ Project-tailored operating instructions for AI coding agentsMakefileβ Convenience tasks for validation (make validate) and search (make search q="...")
4. Running as an MCP Server
okf ships with a native Model Context Protocol (MCP) server over stdio to seamlessly connect with Claude Code, Cursor, Codex, and other agent platforms:
./bin/okf mcp knowledge
Example MCP Configuration (claude_desktop_config.json or Cursor):
{
"mcpServers": {
"okf-memory": {
"command": "/path/to/okf-agent-memory/bin/okf",
"args": ["mcp", "/path/to/project/knowledge"]
}
}
}
π Repository Structure
okf-agent-memory/
βββ docs/ # Normative convention, roadmap & compatibility analysis
β βββ CONVENTION.md # OKF Agent Memory Convention v0.1
β βββ ROADMAP.md # Project roadmap & milestones
β βββ OKF-COMPATIBILITY.md# OKF v0.2 spec compatibility analysis
β βββ ALTERNATIVES.md # Comparison against Mem0, Letta, ad-hoc markdown
βββ knowledge/ # Project's own OKF v0.2 persistent memory bundle
β βββ index.md # Root index declaring okf_version: "0.2"
β βββ log.md # Dated change log (ISO 8601 YYYY-MM-DD)
β βββ project/ # Overview & value propositions
β βββ architecture/ # 5-layer architecture & tooling decisions
β βββ convention/ # Principles & lifecycle workflows
β βββ roadmap/ # Milestones
βββ pkg/okf/ # Zero-dependency Go core library (parser, validator, search, mutate)
βββ cmd/okf/ # Standalone CLI and embedded MCP server (stdio)
βββ AGENTS.md # Operating instructions for AI agents
βββ Makefile # Build, test, validate targets
βββ README.md
π§ͺ Testing & Verification
Run the full test suite and validate the repository's self-documenting knowledge bundle:
make check
π Further Documentation
- Contributing Guide β Development setup, quality gates, and pull request standards.
- Getting Started Guide β Comprehensive onboarding guide for agents and humans.
- CLI & MCP Reference β Complete command-line and protocol tools reference.
- Security & Privacy Guidelines β Data governance, secret prevention, and PII protection rules.
- Multi-Agent Testing & Evaluation β Test scenarios, compatibility matrix, and benchmarks.
- OKF Agent Memory Convention v0.1 β Behavioral rules and lifecycle specification.
- Project Roadmap & Milestones β Phased development plan.
- OKF v0.2 Compatibility Matrix β Specification validation analysis.
- Why OKF Agent Memory? β Detailed value proposition & differentiators.
- Alternatives & Ecosystem Comparison β Comparison with Mem0, Letta, and ad-hoc markdown files.
π License
MIT License. See LICENSE for details.