AI coding agents forget everything between sessions. The bug you debugged for 3 hours. The architecture decision. The Windows gotcha. agentic-cortex gives them persistent, searchable, self-improving memory across sessions and projects — entirely local, zero API costs. Agentic-Cortex is an experimental work in-progress to address similar issues and my answer to problems that have arisen due to too much LLM token consumption and costs that come with it.
Agentic-Cortex v6.7.0 — The 5-Layer Agent Brain + Test-Time Reasoning
Persistent, self-improving memory and orchestration for AI coding agents (Codebuff, Claude Code, Cursor, Codex, OpenCode).
Implements the full 5-Layer Graph Engineering framework:
Prompt Engineering → Context Engineering → Harness Engineering → Loop Engineering → Graph Engineering
Install and forget — auto-injects context via git hooks, infers what you're working on, detects when improvement stalls, coordinates multi-agent teams, and prevents the same mistakes from repeating across projects.
Features
🧠 Zero-Arg Bootstrap
agentic-cortex bootstrap with no arguments. Infers your task from session prompt, git branch, or recent activity. Returns structured XML context.
🔍 Auto Type Detection
save "title" "content" detects the right memory type from content patterns. No --type flag needed.
🌐 Machine-Wide Global Vault
Battle-tested learnings auto-promoted across projects. If you learned it once, you never make the mistake again on this machine.
Top 20% confidence + 2× median utility auto-promote to global vault during reflection. Self-tunes as your project grows.
Code Intelligence
🗺️ XML Codebase Graph
Deterministic static analysis, SHA-256 cached, zero LLM cost. Injected as structured XML, not markdown.
🔬 Symbol-Level Code Index
Every function/method/class with its real body indexed in SQLite. Bootstrap injects task-scoped symbols (relevant files + transitive import closure) with actual code, not just a static map — so agents know the code, not just its shape.
🧬 Semantic Code Search
Symbols are embedded (BGE) and hybrid-searched by meaning. code-index search "token budget calc" --semantic finds the budget-forcing code.
⚡ Change-Aware Ingestion
Git hooks re-parse only the changed files (partial graph regen) and record a "code change" memory after every commit/merge/pull. The index keeps up as the codebase grows.
📝 Distilled Symbol Summaries
One-line LLM summaries (docstring fallback) cached per symbol, so more symbols fit the same token budget.
📊 Usage-Weighted Injection
Every symbol an agent retrieves is tracked (access_count / last_accessed_at) and fed back into task-scoped selection: frequently-needed code wins ties and becomes the fallback when a task matches nothing.
🛡️ Memory-Safe by Default
The ~400MB embedding model is never auto-loaded. Search/bootstrap/sync stay keyword-only unless you opt in with AGENTIC_CORTEX_EMBEDDINGS=1 or an explicit embedding command (code-index embed, search --semantic). No more OOM halts on weak machines.
🗜️ Session Context Compactor
Map-reduce compression of observations or transcripts into a "state so far" summary (~95% smaller) that replaces raw conversation history — attacks the biggest token cost: per-turn history re-sending.
📄 Agent-Optimized knowledge.md
XML-structured, 4× token reduction vs markdown. Built for LLM consumption, not human skimming.
memory_bootstrap(), memory_search_all(), memory_machine_vault(), memory_promote_global(), plus:
| Category | Tools |
| Multi-Agent Mailbox | memory_send / memory_inbox |
| Provider Discovery | memory_provider |
| Recovery | Probe-gated retry |
| Test-Time Reasoning | Tree search, PRM, self-consistency, budget forcing |
| Orchestration | FSM, rules, persona swarm, DAG workflows |
| Meta-Cognition | Plateau detection, failure classification, experience replay |
| Utilities | Prompts, translation store, burst budget, war room, deterministic reasoner (6 modes) |
All via Stdio JSON-RPC.
Memory System
13 Typed Memories
instruction · fact · decision · goal · commitment · preference · relationship · context · event · learning · observation · artifact · error
🔎 Hybrid Search
FTS5 keyword + BGE semantic embeddings (768-dim) + cross-encoder reranking. Falls back gracefully when embeddings unavailable.
📊 Confidence & Provenance Tracking
Every memory scores 0–100 confidence and source (explicit, inferred, observed).
🔗 Save-Time Deduplication
Cosine similarity ≥ 0.97 reinforces existing memories instead of creating duplicates.
🕐 Freshness Scoring
0–100 score combining access recency, confidence, and utility. Auto-archives stale memories.
⏰ Auto-Maintenance Scheduler
Runs freshness updates and archival every ~50 saves, minimum 6 hours between full cycles.
💎 Tiered Memory Crystallization
Raw observations compress upward through layers:
| Layer | Description |
| Raw (1) | Original observations |
| Synthesis (2) | Compressed summaries |
| Principle (3) | Always-injected, load-bearing knowledge |
5-Layer Graph Engineering
| Layer | What It Does |
| Prompt Engineering | Versioned template registry with variable substitution and eval feedback |
| Context Engineering | Hybrid search + reranking for optimal context injection |
| Harness Engineering | 93 MCP tools + webhooks for agent integration |
| Loop Engineering | Self-improvement + plateau detection + breakthrough analysis |
| Graph Engineering | FSM + rules + multi-agent DAG workflows |
Prompt Template Registry
10 versioned, outcome-tracked templates for every LLM call. Render with variable substitution via API or MCP. Centralized prompt evolution powered by eval log feedback.
- Error RCA generates systemic learnings
- Conflict detection finds contradictions
- Evidence-based confidence scoring
- Plateau detection identifies stalled improvement and triggers breakthrough analysis
Orchestration
🔀 Multi-Agent Workflows
DAG-based workflow executor with FSM bridge. Workflow steps can spawn sub-agents tracked in state machines. Built-in workflows: code-review-team, incident-response-squad.
🔄 FSM Orchestration Engine
State machines for coding, debugging, and review workflows. Agents transition between states with guard conditions and entry/exit actions.
📋 Declarative Rule Engine
Priority-based condition→action rules that fire on events. Built-in rules for error escalation, auto-crystallization, and context capture.
🪝 Webhook Support
Hook actions can POST to external HTTP endpoints with template interpolation and configurable retries. Bridge to Slack, PagerDuty, CI pipelines, or any HTTP service.
Test-Time Reasoning 🧪
🌳 Tree of Thoughts / MCTS
Inference-time graph search over reasoning branches. Beam search, MCTS, and greedy strategies with adaptive compute budget.
✅ Process Reward Model (PRM)
3-tier step-level verification: deterministic checks, LLM-as-judge, and memory cross-check. Scores each reasoning step 0.0–1.0.
⚖️ Adaptive Compute Budget
Snell et al. compute-optimal allocation: estimates problem difficulty from memory and adjusts beam width, depth, and token budget.
💻 Program-Aided Reasoning (PAL/PoT)
Generate and execute verification code in a sandbox. Deterministic arithmetic, graph traversal, and constraint checking.
🔄 Reflexion Loop
In-context self-correction: failed reasoning paths become memory, preventing repeated mistakes within the same session.
🗳️ Self-Consistency Decoding
Sample N independent chains with temperature, majority-vote the answer. Optional PRM-weighted voting gives higher-quality paths more influence.
🧊 Budget Forcing (s1)
Enforce minimum reasoning depth by suppressing early stops and appending doubt heuristics. Force conclusion synthesis at upper token bound. Controls compute per problem independently of architectural changes.
Additional Features
| Feature | Description |
| Immutable Evaluation Log | Append-only audit trail (AutoGTM's results.tsv pattern). Every evaluation preserved forever for benchmarking and plateau detection. |
| Intent → Action → Outcome Tracking | Linked triplets with relations for evidence-based learning verification. |
| Multi-Agent Sharing | Namespaced agent sessions with shared memory discovery. |
| Skill/Procedure Extraction | Structured fields (steps, triggers, preconditions, postconditions) with dedicated search. |
| Pre-Loaded Coding Standards | DRY, KISS, SOLID, Clean Code, Karpathy guidelines auto-seeded on init. Always injected into context. |
| Conversation Transcript Ingestion | Regex + LLM fallback extracts decisions, errors, learnings, preferences, and facts from chat logs. |
| Grounded QA | Retrieve relevant memories + LLM answer with source citations. |
| Git Hook Auto-Injection | Context auto-refreshes on checkout, merge, pull, and commit. |
| Multi-Agent Discovery Files | Auto-creates .claude/CLAUDE.md, .cursor/rules/agentic-cortex.mdc, .opencode/agentic-cortex.md. |
| Temporal Queries | Search as-of specific dates or filter by changes since. |
| Daily Summaries | LLM-generated or template-fallback summaries of each day's observations. |
| Obsidian Export | One-way read-only mirror to an Obsidian vault with wikilinks and tag indexes. |
| File Upload | Chunk and embed .md, .txt, .json, .csv, .py, .ts, .prisma, and more into memory. |
| HTTP API Server | Optional REST interface on port 37777 for external tool integration. |
| BGE Embeddings | Xenova/bge-base-en-v1.5 with in-memory LRU cache. |
| Embedding Dimension Mismatch Detection | Warns when stored embeddings don't match current model dimensions. |