@agentmemory/agentmemory 0.8.0 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,672 +7,699 @@
7
7
  Persistent memory for Claude Code, Cursor, Gemini CLI, OpenCode, and any MCP client.
8
8
  </p>
9
9
 
10
+ <p align="center">
11
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
12
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
13
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
14
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
15
+ </p>
16
+
17
+ <p align="center">
18
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-recall.svg"><img src="assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
19
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tokens.svg"><img src="assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
20
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tools.svg"><img src="assets/tags/stat-tools.svg" alt="43 MCP tools" height="38" /></picture>
21
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-hooks.svg"><img src="assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
22
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-deps.svg"><img src="assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
23
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tests.svg"><img src="assets/tags/stat-tests.svg" alt="654 tests passing" height="38" /></picture>
24
+ </p>
25
+
10
26
  <p align="center">
11
27
  <img src="assets/demo.gif" alt="agentmemory demo" width="720" />
12
28
  </p>
13
29
 
14
30
  <p align="center">
15
31
  <a href="#quick-start">Quick Start</a> &bull;
16
- <a href="#why-agentmemory">Why</a> &bull;
17
- <a href="#supported-agents">Agents</a> &bull;
32
+ <a href="#benchmarks">Benchmarks</a> &bull;
33
+ <a href="#vs-competitors">vs Competitors</a> &bull;
34
+ <a href="#works-with-every-agent">Agents</a> &bull;
18
35
  <a href="#how-it-works">How It Works</a> &bull;
19
- <a href="#search">Search</a> &bull;
20
- <a href="#memory-evolution">Memory Evolution</a> &bull;
21
36
  <a href="#mcp-server">MCP</a> &bull;
22
37
  <a href="#real-time-viewer">Viewer</a> &bull;
23
- <a href="#configuration">Configuration</a> &bull;
38
+ <a href="#configuration">Config</a> &bull;
24
39
  <a href="#api">API</a>
25
40
  </p>
26
41
 
27
42
  ---
28
43
 
29
- You explain the same architecture every session. You re-discover the same bugs. You re-teach the same preferences. Built-in memory (CLAUDE.md, .cursorrules) caps out at 200 lines and goes stale. agentmemory fixes this — it silently captures what your agent does, compresses it into searchable memory, and injects the right context when the next session starts. One command. Works across agents.
30
-
31
- **What changes:** Session 1 you set up JWT auth. Session 2 you ask for rate limiting — the agent already knows your auth uses jose middleware in `src/middleware/auth.ts`, your tests cover token validation, and you chose jose over jsonwebtoken for Edge compatibility. No re-explaining. No copy-pasting. The agent just *knows*.
44
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-agents.svg"><img src="assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
45
+
46
+ agentmemory works with any agent that supports hooks, MCP, or REST API. All agents share the same memory server.
47
+
48
+ <table>
49
+ <tr>
50
+ <td align="center" width="12.5%">
51
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
52
+ <strong>Claude Code</strong><br/>
53
+ <sub>12 hooks + MCP + skills</sub>
54
+ </td>
55
+ <td align="center" width="12.5%">
56
+ <a href="integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
57
+ <strong>OpenClaw</strong><br/>
58
+ <sub>MCP + <a href="integrations/openclaw/">plugin</a></sub>
59
+ </td>
60
+ <td align="center" width="12.5%">
61
+ <a href="integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
62
+ <strong>Hermes</strong><br/>
63
+ <sub>MCP + <a href="integrations/hermes/">plugin</a></sub>
64
+ </td>
65
+ <td align="center" width="12.5%">
66
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
67
+ <strong>Cursor</strong><br/>
68
+ <sub>MCP server</sub>
69
+ </td>
70
+ <td align="center" width="12.5%">
71
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
72
+ <strong>Gemini CLI</strong><br/>
73
+ <sub>MCP server</sub>
74
+ </td>
75
+ <td align="center" width="12.5%">
76
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
77
+ <strong>OpenCode</strong><br/>
78
+ <sub>MCP server</sub>
79
+ </td>
80
+ <td align="center" width="12.5%">
81
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
82
+ <strong>Codex CLI</strong><br/>
83
+ <sub>MCP server</sub>
84
+ </td>
85
+ <td align="center" width="12.5%">
86
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
87
+ <strong>Cline</strong><br/>
88
+ <sub>MCP server</sub>
89
+ </td>
90
+ </tr>
91
+ <tr>
92
+ <td align="center" width="12.5%">
93
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
94
+ <strong>Goose</strong><br/>
95
+ <sub>MCP server</sub>
96
+ </td>
97
+ <td align="center" width="12.5%">
98
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
99
+ <strong>Kilo Code</strong><br/>
100
+ <sub>MCP server</sub>
101
+ </td>
102
+ <td align="center" width="12.5%">
103
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
104
+ <strong>Aider</strong><br/>
105
+ <sub>REST API</sub>
106
+ </td>
107
+ <td align="center" width="12.5%">
108
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
109
+ <strong>Claude Desktop</strong><br/>
110
+ <sub>MCP server</sub>
111
+ </td>
112
+ <td align="center" width="12.5%">
113
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
114
+ <strong>Windsurf</strong><br/>
115
+ <sub>MCP server</sub>
116
+ </td>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
119
+ <strong>Roo Code</strong><br/>
120
+ <sub>MCP server</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/anthropics/claude-agent-sdk-typescript"><img src="https://github.com/anthropics.png?size=120" alt="Claude SDK" width="48" height="48" /></a><br/>
124
+ <strong>Claude SDK</strong><br/>
125
+ <sub>AgentSDKProvider</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <img src="https://img.shields.io/badge/109-endpoints-1f6feb?style=flat-square" alt="REST API" width="48" /><br/>
129
+ <strong>Any agent</strong><br/>
130
+ <sub>REST API</sub>
131
+ </td>
132
+ </tr>
133
+ </table>
32
134
 
33
- **95.2% retrieval accuracy** on [LongMemEval](https://arxiv.org/abs/2410.10813) (ICLR 2025). 43 MCP tools. 12 hooks. Real-time viewer. Works with Claude Code, Cursor, Gemini CLI, OpenCode, and any MCP client. 646 tests. Zero external DB dependencies.
34
-
35
- ```bash
36
- npx @agentmemory/agentmemory # installs iii-engine if missing, starts everything
37
- ```
135
+ <p align="center">
136
+ <sub>Works with <strong>any</strong> agent that speaks MCP or HTTP. One server, memories shared across all of them.</sub>
137
+ </p>
38
138
 
39
139
  ---
40
140
 
41
- ## Why agentmemory
141
+ You explain the same architecture every session. You re-discover the same bugs. You re-teach the same preferences. Built-in memory (CLAUDE.md, .cursorrules) caps out at 200 lines and goes stale. agentmemory fixes this. It silently captures what your agent does, compresses it into searchable memory, and injects the right context when the next session starts. One command. Works across agents.
42
142
 
43
- Every coding agent forgets everything when the session ends. You waste the first 5 minutes of every session re-explaining your stack, your conventions, your recent decisions. agentmemory runs in the background and eliminates that entirely.
143
+ **What changes:** Session 1 you set up JWT auth. Session 2 you ask for rate limiting. The agent already knows your auth uses jose middleware in `src/middleware/auth.ts`, your tests cover token validation, and you chose jose over jsonwebtoken for Edge compatibility. No re-explaining. No copy-pasting. The agent just *knows*.
44
144
 
45
- ```
46
- Session 1: "Add auth to the API"
47
- Agent writes code, runs tests, fixes bugs
48
- agentmemory silently captures every tool use
49
- Session ends -> observations compressed into structured memory
50
-
51
- Session 2: "Now add rate limiting"
52
- Agent already knows:
53
- - Auth uses JWT middleware in src/middleware/auth.ts
54
- - Tests in test/auth.test.ts cover token validation
55
- - You chose jose over jsonwebtoken for Edge compatibility
56
- - The rate limit discussion from last week's debugging session
57
- Zero re-explaining. Starts working immediately.
145
+ ```bash
146
+ npx @agentmemory/agentmemory
58
147
  ```
59
148
 
60
- ### What it gives you
149
+ > **New in v0.8.2** — Security hardening (default localhost, viewer CSP nonces, mesh auth), `agentmemory demo` command, benchmark comparison vs mem0/Letta/Khoj, OpenClaw gateway plugin, real-time token savings in CLI + viewer.
61
150
 
62
- | Capability | What it does |
63
- |---|---|
64
- | **Automatic capture** | Every tool use, file edit, test run, and error is silently recorded via hooks |
65
- | **LLM compression** | Raw observations are compressed into structured facts, concepts, and narratives |
66
- | **Context injection** | Past knowledge is injected at session start within a configurable token budget |
67
- | **Semantic search** | Hybrid BM25 + vector search finds relevant memories even with different wording |
68
- | **Memory evolution** | Memories version over time, supersede each other, and form relationship graphs |
69
- | **Project profiles** | Aggregated per-project intelligence: top concepts, files, conventions, common errors |
70
- | **Auto-forgetting** | TTL expiry, contradiction detection, and importance-based eviction keep memory clean |
71
- | **Privacy first** | API keys, secrets, and `<private>` tags are stripped before anything is stored |
72
- | **Self-healing** | Circuit breaker, provider fallback chain, self-correcting LLM output, health monitoring |
73
- | **Claude Code bridge** | Bi-directional sync with `~/.claude/projects/*/memory/MEMORY.md` |
74
- | **Cross-agent MCP** | Standalone MCP server for Cursor, Codex, Gemini CLI, Windsurf, any MCP client |
75
- | **Citation provenance** | JIT verification traces any memory back to source observations and sessions |
76
- | **Cascading staleness** | Superseded memories auto-flag related graph nodes, edges, and siblings as stale |
77
- | **Knowledge graph** | Entity extraction + BFS traversal across files, functions, concepts, errors |
78
- | **4-tier memory** | Working → episodic → semantic → procedural consolidation with strength decay |
79
- | **Team memory** | Namespaced shared + private memory across team members |
80
- | **Governance** | Edit, delete, bulk-delete, and audit trail for all memory operations |
81
- | **Git snapshots** | Version, rollback, and diff memory state via git commits |
82
-
83
- ### How it compares to built-in agent memory
84
-
85
- Every AI coding agent now ships with built-in memory — Claude Code has `MEMORY.md`, Cursor has notepads, Windsurf has Cascade memories, Cline has memory bank. These work like sticky notes: fast, always-on, but fundamentally limited.
86
-
87
- agentmemory is the searchable database behind the sticky notes.
88
-
89
- | | Built-in (CLAUDE.md, .cursorrules) | agentmemory |
90
- |---|---|---|
91
- | Scale | 200-line cap (MEMORY.md) | Unlimited |
92
- | Search | Loads everything into context | BM25 + vector + graph (returns top-K only) |
93
- | Token cost | 22K+ tokens at 240 observations | ~1,900 tokens (92% less) |
94
- | At 1K observations | 80% of memories invisible | 100% searchable |
95
- | At 5K observations | Exceeds context window | Still ~2K tokens |
96
- | Cross-session recall | Only within line cap | Full corpus search |
97
- | Cross-agent | Per-agent files (no sharing) | MCP + REST API (any agent) |
98
- | Multi-agent coordination | Impossible | Leases, signals, actions, routines |
99
- | Cross-agent sync | No | P2P mesh (7 scopes: memories, actions, semantic, procedural, relations, graph) |
100
- | Memory trust | No verification | Citation chain back to source observations with confidence scores |
101
- | Semantic search | No (keyword grep) | Yes (95.2% R@5 on LongMemEval-S) |
102
- | Memory lifecycle | Manual pruning | Ebbinghaus decay + tiered eviction |
103
- | Knowledge graph | No | Entity extraction + temporal versioning |
104
- | Observability | Read files manually | Real-time viewer on :3113 |
105
-
106
- ### Benchmarks (measured, not projected)
107
-
108
- #### LongMemEval-S (ICLR 2025, 500 questions)
109
-
110
- Evaluated on [LongMemEval-S](https://arxiv.org/abs/2410.10813), an academic benchmark with 500 questions across ~48 sessions per question (~115K tokens). Same dataset and metric (`recall_any@K`) used by other memory systems.
111
-
112
- | System | R@5 | R@10 | NDCG@10 | MRR |
113
- |---|---|---|---|---|
114
- | **agentmemory BM25+Vector** | **95.2%** | **98.6%** | **87.9%** | **88.2%** |
115
- | agentmemory BM25-only | 86.2% | 94.6% | 73.0% | 71.5% |
116
-
117
- These are retrieval recall scores (not end-to-end QA accuracy). Embedding model: `all-MiniLM-L6-v2` (local, no API key).
118
-
119
- #### Internal benchmark (240 observations, 20 queries)
151
+ ---
120
152
 
121
- | System | Recall@10 | NDCG@10 | MRR | Tokens/query |
122
- |---|---|---|---|---|
123
- | Built-in (grep all into context) | 55.8% | 80.3% | 82.5% | 19,462 |
124
- | agentmemory BM25 (stemmed + synonyms) | 55.9% | 82.7% | 95.5% | 1,571 |
125
- | agentmemory + Xenova embeddings | **64.1%** | **94.9%** | **100.0%** | **1,571** |
153
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-benchmarks.svg"><img src="assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
126
154
 
127
- agentmemory finds "N+1 query fix" when you search "database performance optimization" — something keyword matching literally cannot do.
155
+ <table>
156
+ <tr>
157
+ <td width="50%">
128
158
 
129
- Full benchmark reports: [`benchmark/LONGMEMEVAL.md`](benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](benchmark/QUALITY.md), [`benchmark/SCALE.md`](benchmark/SCALE.md), [`benchmark/REAL-EMBEDDINGS.md`](benchmark/REAL-EMBEDDINGS.md)
159
+ ### Retrieval Accuracy
130
160
 
131
- ## Supported Agents
161
+ **LongMemEval-S** (ICLR 2025, 500 questions)
132
162
 
133
- agentmemory works with any agent that supports hooks, MCP, or via its REST API.
163
+ | System | R@5 | R@10 | MRR |
164
+ |---|---|---|---|
165
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
166
+ | BM25-only fallback | 86.2% | 94.6% | 71.5% |
134
167
 
135
- ### Native hook support (zero config)
168
+ </td>
169
+ <td width="50%">
136
170
 
137
- These agents support hooks natively. agentmemory captures tool usage automatically via its 12 hooks.
171
+ ### Token Savings
138
172
 
139
- | Agent | Integration | Setup |
173
+ | Approach | Tokens/yr | Cost/yr |
140
174
  |---|---|---|
141
- | **Claude Code** | 12 hooks (all types) | `/plugin install agentmemory` or manual hook config |
142
- | **Claude Code SDK** | Agent SDK provider | Built-in `AgentSDKProvider` uses your Claude subscription |
143
-
144
- ### MCP support (any MCP-compatible agent)
175
+ | Paste full context | 19.5M+ | Impossible (exceeds window) |
176
+ | LLM-summarized | ~650K | ~$500 |
177
+ | **agentmemory** | **~170K** | **~$10** |
178
+ | agentmemory + local embeddings | ~170K | **$0** |
145
179
 
146
- Any agent that connects to MCP servers can use agentmemory's 43 tools, 6 resources, and 3 prompts. The agent actively queries and saves memory through MCP calls.
180
+ </td>
181
+ </tr>
182
+ </table>
147
183
 
148
- | Agent | How to connect |
149
- |---|---|
150
- | **Cursor** | Add MCP server in settings or `~/.cursor/mcp.json` |
151
- | **Claude Desktop** | Add to `claude_desktop_config.json` MCP servers |
152
- | **Gemini CLI** | `gemini mcp add agentmemory -- npx agentmemory-mcp` |
153
- | **OpenCode** | Add to `.opencode/config.json` MCP servers |
154
- | **Cline / Continue** | MCP server configuration |
155
- | **Any MCP client** | Point to `http://localhost:3111/agentmemory/mcp/*` |
156
-
157
- ### REST API (any agent, any language)
184
+ <p align="center">
185
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-recall.svg"><img src="assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="48" /></picture>
186
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tokens.svg"><img src="assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="48" /></picture>
187
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tools.svg"><img src="assets/tags/stat-tools.svg" alt="43 MCP tools" height="48" /></picture>
188
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-hooks.svg"><img src="assets/tags/stat-hooks.svg" alt="12 auto hooks" height="48" /></picture>
189
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-deps.svg"><img src="assets/tags/stat-deps.svg" alt="0 external DBs" height="48" /></picture>
190
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tests.svg"><img src="assets/tags/stat-tests.svg" alt="654 tests passing" height="48" /></picture>
191
+ </p>
158
192
 
159
- Agents without hooks or MCP can integrate via 103 REST endpoints directly. This works with any agent, language, or framework.
193
+ > Embedding model: `all-MiniLM-L6-v2` (local, free, no API key). Full reports: [`benchmark/LONGMEMEVAL.md`](benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](benchmark/QUALITY.md), [`benchmark/SCALE.md`](benchmark/SCALE.md). Competitor comparison: [`benchmark/COMPARISON.md`](benchmark/COMPARISON.md) — agentmemory vs mem0, Letta, Khoj, claude-mem, Hippo.
160
194
 
161
- ```bash
162
- POST /agentmemory/observe # Capture what the agent did
163
- POST /agentmemory/smart-search # Find relevant memories
164
- POST /agentmemory/context # Get context for injection
165
- POST /agentmemory/enrich # Get enriched context (files + memories + bugs)
166
- POST /agentmemory/remember # Save long-term memory
167
- GET /agentmemory/profile # Get project intelligence
168
- ```
195
+ ---
169
196
 
170
- ### Choosing an integration method
197
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-competitors.svg"><img src="assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
198
+
199
+ <table>
200
+ <tr>
201
+ <th width="20%"></th>
202
+ <th width="20%">agentmemory</th>
203
+ <th width="20%">mem0 (53K ⭐)</th>
204
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
205
+ <th width="20%">Built-in (CLAUDE.md)</th>
206
+ </tr>
207
+ <tr>
208
+ <td><strong>Type</strong></td>
209
+ <td>Memory engine + MCP server</td>
210
+ <td>Memory layer API</td>
211
+ <td>Full agent runtime</td>
212
+ <td>Static file</td>
213
+ </tr>
214
+ <tr>
215
+ <td><strong>Retrieval R@5</strong></td>
216
+ <td><strong>95.2%</strong></td>
217
+ <td>68.5% (LoCoMo)</td>
218
+ <td>83.2% (LoCoMo)</td>
219
+ <td>N/A (grep)</td>
220
+ </tr>
221
+ <tr>
222
+ <td><strong>Auto-capture</strong></td>
223
+ <td>12 hooks (zero manual effort)</td>
224
+ <td>Manual <code>add()</code> calls</td>
225
+ <td>Agent self-edits</td>
226
+ <td>Manual editing</td>
227
+ </tr>
228
+ <tr>
229
+ <td><strong>Search</strong></td>
230
+ <td>BM25 + Vector + Graph (RRF fusion)</td>
231
+ <td>Vector + Graph</td>
232
+ <td>Vector (archival)</td>
233
+ <td>Loads everything into context</td>
234
+ </tr>
235
+ <tr>
236
+ <td><strong>Multi-agent</strong></td>
237
+ <td>MCP + REST + leases + signals</td>
238
+ <td>API (no coordination)</td>
239
+ <td>Within Letta runtime only</td>
240
+ <td>Per-agent files</td>
241
+ </tr>
242
+ <tr>
243
+ <td><strong>Framework lock-in</strong></td>
244
+ <td>None (any MCP client)</td>
245
+ <td>None</td>
246
+ <td>High (must use Letta)</td>
247
+ <td>Per-agent format</td>
248
+ </tr>
249
+ <tr>
250
+ <td><strong>External deps</strong></td>
251
+ <td>None (SQLite + iii-engine)</td>
252
+ <td>Qdrant / pgvector</td>
253
+ <td>Postgres + vector DB</td>
254
+ <td>None</td>
255
+ </tr>
256
+ <tr>
257
+ <td><strong>Memory lifecycle</strong></td>
258
+ <td>4-tier consolidation + decay + auto-forget</td>
259
+ <td>Passive extraction</td>
260
+ <td>Agent-managed</td>
261
+ <td>Manual pruning</td>
262
+ </tr>
263
+ <tr>
264
+ <td><strong>Token efficiency</strong></td>
265
+ <td>~1,900 tokens/session ($10/yr)</td>
266
+ <td>Varies by integration</td>
267
+ <td>Core memory in context</td>
268
+ <td>22K+ tokens at 240 obs</td>
269
+ </tr>
270
+ <tr>
271
+ <td><strong>Real-time viewer</strong></td>
272
+ <td>Yes (port 3113)</td>
273
+ <td>Cloud dashboard</td>
274
+ <td>Cloud dashboard</td>
275
+ <td>No</td>
276
+ </tr>
277
+ <tr>
278
+ <td><strong>Self-hosted</strong></td>
279
+ <td>Yes (default)</td>
280
+ <td>Optional</td>
281
+ <td>Optional</td>
282
+ <td>Yes</td>
283
+ </tr>
284
+ </table>
171
285
 
172
- | Your situation | Use |
173
- |---|---|
174
- | Claude Code user | Plugin install (hooks + MCP + skills) |
175
- | Building a custom agent with Claude SDK | AgentSDKProvider (zero config) |
176
- | Using Cursor, Gemini CLI, OpenCode, or any MCP client | MCP server (43 tools + 6 resources + 3 prompts) |
177
- | Building your own agent framework | REST API (103 endpoints) |
178
- | Sharing memory across multiple agents | All agents point to the same iii-engine instance |
286
+ ---
179
287
 
180
- ## Quick Start
288
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-quickstart.svg"><img src="assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
181
289
 
182
- ### 1. Start agentmemory
290
+ ### Try it in 30 seconds
183
291
 
184
292
  ```bash
293
+ # Terminal 1: start the server
185
294
  npx @agentmemory/agentmemory
186
- ```
187
295
 
188
- This auto-installs iii-engine if missing, starts it, and runs the worker. One command.
189
-
190
- Or from source:
191
-
192
- ```bash
193
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
194
- npm install && npm run build && npm start
296
+ # Terminal 2: seed sample data and see recall in action
297
+ npx @agentmemory/agentmemory demo
195
298
  ```
196
299
 
197
- ### 2. Connect your agent
300
+ `demo` seeds 3 realistic sessions (JWT auth, N+1 query fix, rate limiting) and runs semantic searches against them. You'll see it find "N+1 query fix" when you search "database performance optimization" — keyword matching can't do that.
198
301
 
199
- **Claude Code (plugin hooks + MCP + skills):**
302
+ Open `http://localhost:3113` to watch the memory build live.
200
303
 
201
- ```bash
202
- /plugin marketplace add rohitg00/agentmemory
203
- /plugin install agentmemory
204
- ```
304
+ ### Claude Code (one block, paste it)
205
305
 
206
- All 12 hooks, 4 skills, and MCP server are registered automatically.
306
+ ```
307
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` to register all 12 hooks, 4 skills, and 43 MCP tools. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
308
+ ```
207
309
 
208
- **Cursor / Claude Desktop / Cline / any MCP client:**
310
+ <details>
311
+ <summary><b>OpenClaw (paste this prompt)</b></summary>
209
312
 
210
- Add to your MCP config (e.g. `~/.cursor/mcp.json`, `claude_desktop_config.json`):
313
+ ```
314
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 43 memory tools:
211
315
 
212
- ```json
213
316
  {
214
317
  "mcpServers": {
215
318
  "agentmemory": {
216
319
  "command": "npx",
217
- "args": ["agentmemory-mcp"]
320
+ "args": ["-y", "agentmemory-mcp"]
218
321
  }
219
322
  }
220
323
  }
221
- ```
222
-
223
- **Gemini CLI:**
224
324
 
225
- ```bash
226
- gemini mcp add agentmemory -- npx agentmemory-mcp
325
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 4-hook gateway integration, see integrations/openclaw in the agentmemory repo.
227
326
  ```
228
327
 
229
- **OpenCode:**
328
+ Full guide: [`integrations/openclaw/`](integrations/openclaw/)
230
329
 
231
- Add to `.opencode/config.json`:
330
+ </details>
331
+
332
+ <details>
333
+ <summary><b>Hermes Agent (paste this prompt)</b></summary>
232
334
 
233
- ```json
234
- {
235
- "mcpServers": {
236
- "agentmemory": {
237
- "command": "npx",
238
- "args": ["agentmemory-mcp"]
239
- }
240
- }
241
- }
242
335
  ```
336
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 43 memory tools:
243
337
 
244
- **Any agent via SkillKit (32+ agents supported):**
338
+ mcp_servers:
339
+ agentmemory:
340
+ command: npx
341
+ args: ["-y", "agentmemory-mcp"]
245
342
 
246
- ```bash
247
- npx skillkit install agentmemory
343
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/memory/agentmemory.
248
344
  ```
249
345
 
250
- **REST API (any agent, any language):**
346
+ Full guide: [`integrations/hermes/`](integrations/hermes/)
251
347
 
252
- ```bash
253
- curl -X POST http://localhost:3111/agentmemory/remember \
254
- -H "Content-Type: application/json" \
255
- -d '{"content": "Always use jose for JWT on Edge", "type": "preference"}'
348
+ </details>
256
349
 
257
- curl -X POST http://localhost:3111/agentmemory/smart-search \
258
- -H "Content-Type: application/json" \
259
- -d '{"query": "JWT authentication"}'
260
- ```
350
+ ### Other agents
351
+
352
+ Start the memory server: `npx @agentmemory/agentmemory`
261
353
 
262
- ### 3. Verify
354
+ Then add the MCP config for your agent:
355
+
356
+ | Agent | Setup |
357
+ |---|---|
358
+ | **Cursor** | Add to `~/.cursor/mcp.json`: `{"mcpServers": {"agentmemory": {"command": "npx", "args": ["-y", "agentmemory-mcp"]}}}` |
359
+ | **OpenClaw** | Add to MCP config: `{"mcpServers": {"agentmemory": {"command": "npx", "args": ["-y", "agentmemory-mcp"]}}}` or use the [gateway plugin](integrations/openclaw/) |
360
+ | **Gemini CLI** | `gemini mcp add agentmemory -- npx -y agentmemory-mcp` |
361
+ | **Codex CLI** | Add to `.codex/config.yaml`: `mcp_servers: {agentmemory: {command: npx, args: ["-y", "agentmemory-mcp"]}}` |
362
+ | **OpenCode** | Add to `opencode.json`: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "agentmemory-mcp"], "enabled": true}}}` |
363
+ | **Hermes Agent** | Add to `~/.hermes/config.yaml` or use the [memory provider plugin](integrations/hermes/) |
364
+ | **Cline / Goose / Kilo Code** | Add MCP server in settings |
365
+ | **Claude Desktop** | Add to `claude_desktop_config.json`: `{"mcpServers": {"agentmemory": {"command": "npx", "args": ["-y", "agentmemory-mcp"]}}}` |
366
+ | **Aider** | REST API: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'` |
367
+ | **Any agent (32+)** | `npx skillkit install agentmemory` |
368
+
369
+ ### From source
263
370
 
264
371
  ```bash
265
- curl http://localhost:3111/agentmemory/health
266
- open http://localhost:3113 # Real-time viewer
372
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
373
+ npm install && npm run build && npm start
267
374
  ```
268
375
 
269
- ```json
270
- {
271
- "status": "healthy",
272
- "service": "agentmemory",
273
- "version": "0.7.7",
274
- "health": {
275
- "memory": { "heapUsed": 42000000, "heapTotal": 67000000 },
276
- "cpu": { "percent": 2.1 },
277
- "eventLoopLagMs": 1.2,
278
- "status": "healthy"
279
- },
280
- "circuitBreaker": { "state": "closed", "failures": 0 }
281
- }
282
- ```
376
+ This starts agentmemory with a local `iii-engine` if `iii` is already installed, or falls back to Docker Compose if Docker is available. REST, streams, and the viewer bind to `127.0.0.1` by default.
283
377
 
284
- ### Manual Hook Setup (alternative)
378
+ Install `iii-engine` manually:
285
379
 
286
- If you prefer not to use the plugin, add hooks directly to `~/.claude/settings.json`:
380
+ - **macOS / Linux:** `curl -fsSL https://install.iii.dev/iii/main/install.sh | sh`
381
+ - **Windows:** download `iii-x86_64-pc-windows-msvc.zip` from [iii-hq/iii releases](https://github.com/iii-hq/iii/releases/latest), extract `iii.exe`, add to PATH
287
382
 
288
- ```json
289
- {
290
- "hooks": {
291
- "SessionStart": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/session-start.mjs" }],
292
- "UserPromptSubmit": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/prompt-submit.mjs" }],
293
- "PreToolUse": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/pre-tool-use.mjs" }],
294
- "PostToolUse": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/post-tool-use.mjs" }],
295
- "PostToolUseFailure": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/post-tool-failure.mjs" }],
296
- "PreCompact": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/pre-compact.mjs" }],
297
- "SubagentStart": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/subagent-start.mjs" }],
298
- "SubagentStop": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/subagent-stop.mjs" }],
299
- "Notification": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/notification.mjs" }],
300
- "TaskCompleted": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/task-completed.mjs" }],
301
- "Stop": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/stop.mjs" }],
302
- "SessionEnd": [{ "type": "command", "command": "node ~/agentmemory/dist/hooks/session-end.mjs" }]
303
- }
304
- }
305
- ```
383
+ Or use Docker (the bundled `docker-compose.yml` pulls `iiidev/iii:latest`). Full docs: [iii.dev/docs](https://iii.dev/docs).
306
384
 
307
- ## First Steps After Install
385
+ ### Windows
308
386
 
309
- Once hooks are installed, memory builds silently. No action neededjust use your agent normally.
387
+ agentmemory runs on Windows 10/11, but the Node.js package alone isn't enough you also need the `iii-engine` runtime (a separate native binary) as a background process. The official upstream installer is a `sh` script and there is no PowerShell installer or scoop/winget package today, so Windows users have two paths:
310
388
 
311
- ### Session 1: Your agent works as usual
389
+ **Option A Prebuilt Windows binary (recommended):**
312
390
 
313
- ```text
314
- You: "Add JWT auth to the Express API"
315
- Agent: reads files, writes code, runs tests, fixes errors
391
+ ```powershell
392
+ # 1. Open https://github.com/iii-hq/iii/releases/latest in your browser
393
+ # 2. Download iii-x86_64-pc-windows-msvc.zip
394
+ # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
395
+ # 3. Extract iii.exe somewhere on PATH, or place it at:
396
+ # %USERPROFILE%\.local\bin\iii.exe
397
+ # (agentmemory checks that location automatically)
398
+ # 4. Verify:
399
+ iii --version
400
+
401
+ # 5. Then run agentmemory as usual:
402
+ npx -y @agentmemory/agentmemory
316
403
  ```
317
404
 
318
- agentmemory captures every tool use via PostToolUse hooks. At session end, 47 raw observations compress into structured memory:
405
+ **Option B Docker Desktop:**
319
406
 
320
- ```json
321
- {
322
- "type": "file_edit",
323
- "title": "Implement JWT middleware with jose",
324
- "facts": ["Using jose library for Edge compatibility", "JWT tokens expire after 30 days", "Middleware in src/middleware/auth.ts"],
325
- "concepts": ["jwt", "authentication", "jose", "middleware"],
326
- "files": ["src/middleware/auth.ts", "src/app/api/auth/route.ts"],
327
- "importance": 9
328
- }
407
+ ```powershell
408
+ # 1. Install Docker Desktop for Windows
409
+ # 2. Start Docker Desktop and make sure the engine is running
410
+ # 3. Run agentmemory it will auto-start the bundled compose file:
411
+ npx -y @agentmemory/agentmemory
329
412
  ```
330
413
 
331
- ### Session 2: The payoff
332
-
333
- You start a new session. Before the agent responds, the SessionStart hook fires and injects context (~1,900 tokens):
414
+ **Option C standalone MCP only (no engine):** if you only need the MCP tools for your agent and don't need the REST API, viewer, or cron jobs, skip the engine entirely:
334
415
 
335
- ```text
336
- Agent already knows:
337
- - Auth uses jose JWT middleware in src/middleware/auth.ts
338
- - Tests in test/auth.test.ts cover token validation
339
- - You chose jose over jsonwebtoken for Edge compatibility
340
- - Rate limiting discussion from last week's debugging session
416
+ ```powershell
417
+ npx -y @agentmemory/agentmemory mcp
418
+ # or via the shim package:
419
+ npx -y agentmemory-mcp
341
420
  ```
342
421
 
343
- No re-explaining. The agent starts working immediately.
422
+ **Diagnostics for Windows:** if `npx @agentmemory/agentmemory` fails, re-run with `--verbose` to see the actual engine stderr. Common failure modes:
344
423
 
345
- ### How to verify it's working
424
+ | Symptom | Fix |
425
+ |---|---|
426
+ | `iii-engine process started` then `did not become ready within 15s` | Engine crashed on startup — re-run with `--verbose`, check stderr |
427
+ | `Could not start iii-engine` | Neither `iii.exe` nor Docker is installed. See Option A or B above |
428
+ | Port conflict | `netstat -ano \| findstr :3111` to see what's bound, then kill it or use `--port <N>` |
429
+ | Docker fallback skipped even though Docker is installed | Make sure Docker Desktop is actually running (system tray icon) |
346
430
 
347
- ```bash
348
- npx @agentmemory/agentmemory status # quick terminal check
349
- curl http://localhost:3111/agentmemory/health
350
- open http://localhost:3113 # real-time viewer
351
- ```
431
+ > Note: there is no `cargo install iii-engine` — `iii` is not published to crates.io. The only supported install methods are the prebuilt binary above, the upstream `sh` install script (macOS/Linux only), and the Docker image.
352
432
 
353
- After 1 session: check the Timeline tab in the viewer. After 2+ sessions: check Dashboard for memory count > 0 and the Token Savings card.
433
+ ---
354
434
 
355
- ## How It Works
435
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-why.svg"><img src="assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
356
436
 
357
- ### Observation Pipeline
437
+ Every coding agent forgets everything when the session ends. You waste the first 5 minutes of every session re-explaining your stack. agentmemory runs in the background and eliminates that entirely.
358
438
 
359
439
  ```
360
- PostToolUse hook fires
361
- -> Dedup check SHA-256 hash (5min window, no duplicates)
362
- -> mem::privacy Strip secrets, API keys, <private> tags
363
- -> mem::observe Store raw observation, push to real-time stream
364
- -> mem::compress LLM extracts: type, facts, narrative, concepts, files
365
- Validates with Zod, scores quality (0-100)
366
- Self-corrects on validation failure (1 retry)
367
- Generates vector embedding for semantic search
368
- ```
369
-
370
- ### Context Injection
440
+ Session 1: "Add auth to the API"
441
+ Agent writes code, runs tests, fixes bugs
442
+ agentmemory silently captures every tool use
443
+ Session ends -> observations compressed into structured memory
371
444
 
445
+ Session 2: "Now add rate limiting"
446
+ Agent already knows:
447
+ - Auth uses JWT middleware in src/middleware/auth.ts
448
+ - Tests in test/auth.test.ts cover token validation
449
+ - You chose jose over jsonwebtoken for Edge compatibility
450
+ Zero re-explaining. Starts working immediately.
372
451
  ```
373
- SessionStart hook fires
374
- -> mem::context Load recent sessions for this project
375
- Hybrid search (BM25 + vector) across observations
376
- Inject project profile (top concepts, files, patterns)
377
- Apply token budget (default: 2000 tokens)
378
- -> stdout Agent receives context in the conversation
379
- ```
380
-
381
- ### What Gets Captured
382
452
 
383
- | Hook | Captures |
384
- |------|----------|
385
- | `SessionStart` | Project path, session ID, working directory |
386
- | `UserPromptSubmit` | User prompts (privacy-filtered) |
387
- | `PreToolUse` | File access patterns + enriched context injection (Read, Write, Edit, Glob, Grep) |
388
- | `PostToolUse` | Tool name, input, output |
389
- | `PostToolUseFailure` | Failed tool invocations with error context |
390
- | `PreCompact` | Re-injects memory context before context compaction |
391
- | `SubagentStart/Stop` | Sub-agent lifecycle events |
392
- | `Notification` | System notifications |
393
- | `TaskCompleted` | Task completion events |
394
- | `Stop` | Triggers end-of-session summary |
395
- | `SessionEnd` | Marks session complete |
453
+ ### vs built-in agent memory
396
454
 
397
- ## Search
455
+ Every AI coding agent ships with built-in memory — Claude Code has `MEMORY.md`, Cursor has notepads, Cline has memory bank. These work like sticky notes. agentmemory is the searchable database behind the sticky notes.
398
456
 
399
- agentmemory uses triple-stream retrieval combining three signals for maximum recall.
400
-
401
- ### How search works
402
-
403
- | Stream | What it does | When |
457
+ | | Built-in (CLAUDE.md) | agentmemory |
404
458
  |---|---|---|
405
- | **BM25** | Stemmed keyword matching with synonym expansion and binary-search prefix matching | Always on |
406
- | **Vector** | Cosine similarity over dense embeddings (Xenova, OpenAI, Gemini, Voyage, Cohere, OpenRouter) | Any embedding provider configured |
407
- | **Graph** | Knowledge graph traversal via entity matching and co-occurrence edges | Entities detected in query |
408
-
409
- All three streams are fused with Reciprocal Rank Fusion (RRF, k=60) and session-diversified (max 3 results per session) to maximize coverage.
459
+ | Scale | 200-line cap | Unlimited |
460
+ | Search | Loads everything into context | BM25 + vector + graph (top-K only) |
461
+ | Token cost | 22K+ at 240 observations | ~1,900 tokens (92% less) |
462
+ | Cross-agent | Per-agent files | MCP + REST (any agent) |
463
+ | Coordination | None | Leases, signals, actions, routines |
464
+ | Observability | Read files manually | Real-time viewer on :3113 |
410
465
 
411
- **BM25 enhancements (v0.6.0):** Porter stemmer normalizes word forms ("authentication" ↔ "authenticating"), coding-domain synonyms expand queries ("db" ↔ "database", "perf" ↔ "performance"), and binary-search prefix matching replaces O(n) scans.
466
+ ---
412
467
 
413
- ### Embedding providers
468
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-how.svg"><img src="assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
414
469
 
415
- agentmemory auto-detects which provider to use. For best results, install local embeddings (no API key needed):
470
+ ### Memory Pipeline
416
471
 
417
- ```bash
418
- npm install @xenova/transformers
419
472
  ```
473
+ PostToolUse hook fires
474
+ -> SHA-256 dedup (5min window)
475
+ -> Privacy filter (strip secrets, API keys)
476
+ -> Store raw observation
477
+ -> LLM compress -> structured facts + concepts + narrative
478
+ -> Vector embedding (6 providers + local)
479
+ -> Index in BM25 + vector + knowledge graph
420
480
 
421
- | Provider | Model | Dimensions | Env Var | Notes |
422
- |---|---|---|---|---|
423
- | **Local (recommended)** | `all-MiniLM-L6-v2` | 384 | `EMBEDDING_PROVIDER=local` | Free, offline, +8pp recall over BM25-only |
424
- | Gemini | `text-embedding-004` | 768 | `GEMINI_API_KEY` | Free tier (1500 RPM) |
425
- | OpenAI | `text-embedding-3-small` | 1536 | `OPENAI_API_KEY` | $0.02/1M tokens |
426
- | Voyage AI | `voyage-code-3` | 1024 | `VOYAGE_API_KEY` | Optimized for code |
427
- | Cohere | `embed-english-v3.0` | 1024 | `COHERE_API_KEY` | Free trial available |
428
- | OpenRouter | Any embedding model | varies | `OPENROUTER_API_KEY` | Multi-model proxy |
429
-
430
- No embedding provider? BM25-only mode with stemming and synonyms still outperforms built-in memory.
431
-
432
- ### Progressive disclosure
433
-
434
- Smart search returns compact results first (title, type, score, timestamp) to save tokens. Expand specific IDs to get full observation details.
435
-
436
- ```bash
437
- # Compact results (50-100 tokens each)
438
- curl -X POST http://localhost:3111/agentmemory/smart-search \
439
- -d '{"query": "database migration"}'
440
-
441
- # Expand specific results (500-1000 tokens each)
442
- curl -X POST http://localhost:3111/agentmemory/smart-search \
443
- -d '{"expandIds": ["obs_abc123", "obs_def456"]}'
481
+ SessionStart hook fires
482
+ -> Load project profile (top concepts, files, patterns)
483
+ -> Hybrid search (BM25 + vector + graph)
484
+ -> Token budget (default: 2000 tokens)
485
+ -> Inject into conversation
444
486
  ```
445
487
 
446
- ## Memory Evolution
447
-
448
- Memories in agentmemory are not static. They version, evolve, and form relationships.
488
+ ### 4-Tier Memory Consolidation
449
489
 
450
- ### Versioning
490
+ Inspired by how human brains process memory — not unlike sleep consolidation.
451
491
 
452
- When you save a memory that's similar to an existing one (Jaccard > 0.7), the old memory is superseded:
492
+ | Tier | What | Analogy |
493
+ |------|------|---------|
494
+ | **Working** | Raw observations from tool use | Short-term memory |
495
+ | **Episodic** | Compressed session summaries | "What happened" |
496
+ | **Semantic** | Extracted facts and patterns | "What I know" |
497
+ | **Procedural** | Workflows and decision patterns | "How to do it" |
453
498
 
454
- ```
455
- v1: "Use Express for API routes"
456
- v2: "Use Fastify instead of Express for API routes" (supersedes v1)
457
- v3: "Use Hono instead of Fastify for Edge API routes" (supersedes v2)
458
- ```
499
+ Memories decay over time (Ebbinghaus curve). Frequently accessed memories strengthen. Stale memories auto-evict. Contradictions are detected and resolved.
459
500
 
460
- Only the latest version is returned in search results. The full chain is preserved for audit.
461
-
462
- ### Relationships
463
-
464
- Memories can be linked: `supersedes`, `extends`, `derives`, `contradicts`, `related`. Each relationship carries a confidence score (0-1) computed from co-occurrence, recency, and relation type. Traversal follows these links up to N hops, with optional `minConfidence` filtering.
501
+ ### What Gets Captured
465
502
 
466
- ### Auto-forget
503
+ | Hook | Captures |
504
+ |------|----------|
505
+ | `SessionStart` | Project path, session ID |
506
+ | `UserPromptSubmit` | User prompts (privacy-filtered) |
507
+ | `PreToolUse` | File access patterns + enriched context |
508
+ | `PostToolUse` | Tool name, input, output |
509
+ | `PostToolUseFailure` | Error context |
510
+ | `PreCompact` | Re-injects memory before compaction |
511
+ | `SubagentStart/Stop` | Sub-agent lifecycle |
512
+ | `Stop` | End-of-session summary |
513
+ | `SessionEnd` | Session complete marker |
467
514
 
468
- agentmemory automatically cleans itself:
515
+ ### Key Capabilities
469
516
 
470
- | Mechanism | What it does |
517
+ | Capability | Description |
471
518
  |---|---|
472
- | **TTL expiry** | Memories with `forgetAfter` date are deleted when expired |
473
- | **Contradiction detection** | Near-duplicate memories (Jaccard > 0.9) older one is demoted |
474
- | **Low-value eviction** | Observations older than 90 days with importance < 3 are removed |
475
- | **Per-project cap** | Projects are capped at 10,000 observations (lowest importance evicted first) |
476
-
477
- Run `POST /agentmemory/auto-forget?dryRun=true` to preview what would be cleaned.
478
-
479
- ### Project profiles
519
+ | **Automatic capture** | Every tool use recorded via hooks zero manual effort |
520
+ | **Semantic search** | BM25 + vector + knowledge graph with RRF fusion |
521
+ | **Memory evolution** | Versioning, supersession, relationship graphs |
522
+ | **Auto-forgetting** | TTL expiry, contradiction detection, importance eviction |
523
+ | **Privacy first** | API keys, secrets, `<private>` tags stripped before storage |
524
+ | **Self-healing** | Circuit breaker, provider fallback chain, health monitoring |
525
+ | **Claude bridge** | Bi-directional sync with MEMORY.md |
526
+ | **Knowledge graph** | Entity extraction + BFS traversal |
527
+ | **Team memory** | Namespaced shared + private across team members |
528
+ | **Citation provenance** | Trace any memory back to source observations |
529
+ | **Git snapshots** | Version, rollback, and diff memory state |
480
530
 
481
- agentmemory aggregates observations into per-project intelligence:
531
+ ---
482
532
 
483
- ```bash
484
- curl "http://localhost:3111/agentmemory/profile?project=/my/project"
485
- ```
533
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-search.svg"><img src="assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
486
534
 
487
- Returns top concepts, most-touched files, coding conventions, common errors, and a session count. This profile is automatically injected into session context.
535
+ Triple-stream retrieval combining three signals:
488
536
 
489
- ### Timeline
537
+ | Stream | What it does | When |
538
+ |---|---|---|
539
+ | **BM25** | Stemmed keyword matching with synonym expansion | Always on |
540
+ | **Vector** | Cosine similarity over dense embeddings | Embedding provider configured |
541
+ | **Graph** | Knowledge graph traversal via entity matching | Entities detected in query |
490
542
 
491
- Navigate observations chronologically around any anchor point:
543
+ Fused with Reciprocal Rank Fusion (RRF, k=60) and session-diversified (max 3 results per session).
492
544
 
493
- ```bash
494
- curl -X POST http://localhost:3111/agentmemory/timeline \
495
- -d '{"anchor": "2026-02-15", "before": 5, "after": 5}'
496
- ```
497
-
498
- ### Export / Import
545
+ ### Embedding providers
499
546
 
500
- Full data portability:
547
+ agentmemory auto-detects your provider. For best results, install local embeddings (free):
501
548
 
502
549
  ```bash
503
- # Export everything
504
- curl http://localhost:3111/agentmemory/export > backup.json
505
-
506
- # Import with merge strategy
507
- curl -X POST http://localhost:3111/agentmemory/import \
508
- -d '{"exportData": ..., "strategy": "merge"}'
550
+ npm install @xenova/transformers
509
551
  ```
510
552
 
511
- Strategies: `merge` (combine), `replace` (overwrite), `skip` (ignore duplicates).
512
-
513
- ## Self-Evaluation
514
-
515
- agentmemory monitors its own health and validates its own output.
553
+ | Provider | Model | Cost | Notes |
554
+ |---|---|---|---|
555
+ | **Local (recommended)** | `all-MiniLM-L6-v2` | Free | Offline, +8pp recall over BM25-only |
556
+ | Gemini | `text-embedding-004` | Free tier | 1500 RPM |
557
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | Highest quality |
558
+ | Voyage AI | `voyage-code-3` | Paid | Optimized for code |
559
+ | Cohere | `embed-english-v3.0` | Free trial | General purpose |
560
+ | OpenRouter | Any model | Varies | Multi-model proxy |
516
561
 
517
- ### Quality scoring
518
-
519
- Every LLM compression is scored 0-100 based on structured facts, narrative quality, concept extraction, title quality, and importance range. Scores are tracked per-function and exposed via `/health`.
562
+ ---
520
563
 
521
- ### Self-correction
564
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-mcp.svg"><img src="assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
522
565
 
523
- When LLM output fails Zod validation, agentmemory retries with a stricter prompt explaining the exact errors. This recovers from malformed JSON, missing fields, and out-of-range values.
566
+ 43 tools, 6 resources, 3 prompts, and 4 skills the most comprehensive MCP memory toolkit for any agent.
524
567
 
525
- ### Circuit breaker + fallback chain
568
+ ### 43 Tools
526
569
 
527
- ```
528
- Primary provider fails
529
- -> Circuit breaker opens (3 failures in 60s)
530
- -> Falls back to next provider in FALLBACK_PROVIDERS chain
531
- -> 30s cooldown -> half-open -> test call -> recovery
532
- ```
570
+ <details>
571
+ <summary>Core tools (always available)</summary>
533
572
 
534
- Configure with `FALLBACK_PROVIDERS=anthropic,gemini,openrouter`. When all providers are down, observations are stored raw without compression. No data is lost.
535
-
536
- ### Health monitor
537
-
538
- Collects every 30 seconds: heap usage, CPU percentage (delta sampling), event loop lag, connection state. Alerts at warning (80% CPU, 100ms lag) and critical (90% CPU, 500ms lag) thresholds. `GET /agentmemory/health` returns HTTP 503 when critical.
573
+ | Tool | Description |
574
+ |------|-------------|
575
+ | `memory_recall` | Search past observations |
576
+ | `memory_save` | Save an insight, decision, or pattern |
577
+ | `memory_smart_search` | Hybrid semantic + keyword search |
578
+ | `memory_file_history` | Past observations about specific files |
579
+ | `memory_sessions` | List recent sessions |
580
+ | `memory_profile` | Project profile (concepts, files, patterns) |
581
+ | `memory_export` | Export all memory data |
539
582
 
540
- ## MCP Server
583
+ </details>
541
584
 
542
- ### Tools (43)
585
+ <details>
586
+ <summary>Extended tools (43 total — set AGENTMEMORY_TOOLS=all)</summary>
543
587
 
544
588
  | Tool | Description |
545
589
  |------|-------------|
546
- | `memory_recall` | Search past observations by keyword |
547
- | `memory_save` | Save an insight, decision, or pattern |
548
- | `memory_file_history` | Get past observations about specific files |
549
- | `memory_patterns` | Detect recurring patterns across sessions |
550
- | `memory_sessions` | List recent sessions with status |
551
- | `memory_smart_search` | Hybrid semantic + keyword search with progressive disclosure |
552
- | `memory_timeline` | Chronological observations around an anchor point |
553
- | `memory_profile` | Project profile with top concepts, files, patterns |
554
- | `memory_export` | Export all memory data as JSON |
555
- | `memory_relations` | Query memory relationship graph (with confidence filtering) |
556
- | `memory_claude_bridge_sync` | Sync memory to/from Claude Code's native MEMORY.md |
557
- | `memory_graph_query` | Query the knowledge graph for entities and relationships |
558
- | `memory_consolidate` | Run 4-tier memory consolidation pipeline |
559
- | `memory_team_share` | Share a memory or observation with team members |
560
- | `memory_team_feed` | Get recent shared items from all team members |
561
- | `memory_audit` | View the audit trail of memory operations |
562
- | `memory_governance_delete` | Delete specific memories with audit trail |
563
- | `memory_snapshot_create` | Create a git-versioned snapshot of memory state |
564
- | `memory_action_create` | Create actionable work items with typed dependencies |
565
- | `memory_action_update` | Update action status, priority, or details |
566
- | `memory_frontier` | Get unblocked actions ranked by priority and urgency |
567
- | `memory_next` | Get the single most important next action |
568
- | `memory_lease` | Acquire, release, or renew exclusive action leases |
569
- | `memory_routine_run` | Instantiate a frozen workflow routine into action chains |
570
- | `memory_signal_send` | Send threaded messages between agents |
571
- | `memory_signal_read` | Read messages for an agent with read receipts |
572
- | `memory_checkpoint` | Create or resolve external condition gates (CI, approval, deploy) |
573
- | `memory_mesh_sync` | Sync memories and actions with peer instances |
574
- | `memory_sentinel_create` | Create event-driven condition watchers |
575
- | `memory_sentinel_trigger` | Externally fire a sentinel to unblock gated actions |
576
- | `memory_sketch_create` | Create ephemeral action graphs for exploratory work |
577
- | `memory_sketch_promote` | Promote sketch actions to permanent actions |
578
- | `memory_crystallize` | LLM-powered compaction of completed action chains |
579
- | `memory_diagnose` | Health checks across all subsystems |
580
- | `memory_heal` | Auto-fix stuck, orphaned, and inconsistent state |
581
- | `memory_facet_tag` | Attach structured dimension:value tags to targets |
582
- | `memory_facet_query` | Query targets by facet tags with AND/OR logic |
583
- | `memory_verify` | Trace a memory's provenance back to source observations and sessions |
584
-
585
- ### Resources (6)
586
-
587
- | URI | Description |
588
- |-----|-------------|
589
- | `agentmemory://status` | Session count, memory count, health status |
590
- | `agentmemory://project/{name}/profile` | Per-project intelligence (concepts, files, conventions) |
591
- | `agentmemory://project/{name}/recent` | Last 5 session summaries for a project |
592
- | `agentmemory://memories/latest` | Latest 10 active memories (id, title, type, strength) |
593
- | `agentmemory://graph/stats` | Knowledge graph node and edge counts by type |
594
- | `agentmemory://team/{id}/profile` | Team memory profile with shared concepts and patterns |
595
-
596
- ### Prompts (3)
597
-
598
- | Prompt | Arguments | Description |
599
- |--------|-----------|-------------|
600
- | `recall_context` | `task_description` | Searches observations + memories, returns context messages |
601
- | `session_handoff` | `session_id` | Returns session data + summary for handoff between agents |
602
- | `detect_patterns` | `project` (optional) | Analyzes recurring patterns across sessions |
603
-
604
- ### Standalone MCP Server
605
-
606
- Run agentmemory as a standalone MCP server for any MCP-compatible agent (Cursor, Gemini CLI, OpenCode, Claude Desktop, Cline):
590
+ | `memory_patterns` | Detect recurring patterns |
591
+ | `memory_timeline` | Chronological observations |
592
+ | `memory_relations` | Query relationship graph |
593
+ | `memory_graph_query` | Knowledge graph traversal |
594
+ | `memory_consolidate` | Run 4-tier consolidation |
595
+ | `memory_claude_bridge_sync` | Sync with MEMORY.md |
596
+ | `memory_team_share` | Share with team members |
597
+ | `memory_team_feed` | Recent shared items |
598
+ | `memory_audit` | Audit trail of operations |
599
+ | `memory_governance_delete` | Delete with audit trail |
600
+ | `memory_snapshot_create` | Git-versioned snapshot |
601
+ | `memory_action_create` | Create work items with dependencies |
602
+ | `memory_action_update` | Update action status |
603
+ | `memory_frontier` | Unblocked actions ranked by priority |
604
+ | `memory_next` | Single most important next action |
605
+ | `memory_lease` | Exclusive action leases (multi-agent) |
606
+ | `memory_routine_run` | Instantiate workflow routines |
607
+ | `memory_signal_send` | Inter-agent messaging |
608
+ | `memory_signal_read` | Read messages with receipts |
609
+ | `memory_checkpoint` | External condition gates |
610
+ | `memory_mesh_sync` | P2P sync between instances |
611
+ | `memory_sentinel_create` | Event-driven watchers |
612
+ | `memory_sentinel_trigger` | Fire sentinels externally |
613
+ | `memory_sketch_create` | Ephemeral action graphs |
614
+ | `memory_sketch_promote` | Promote to permanent |
615
+ | `memory_crystallize` | Compact action chains |
616
+ | `memory_diagnose` | Health checks |
617
+ | `memory_heal` | Auto-fix stuck state |
618
+ | `memory_facet_tag` | Dimension:value tags |
619
+ | `memory_facet_query` | Query by facet tags |
620
+ | `memory_verify` | Trace provenance |
621
+
622
+ </details>
623
+
624
+ ### 6 Resources · 3 Prompts · 4 Skills
625
+
626
+ | Type | Name | Description |
627
+ |------|------|-------------|
628
+ | Resource | `agentmemory://status` | Health, session count, memory count |
629
+ | Resource | `agentmemory://project/{name}/profile` | Per-project intelligence |
630
+ | Resource | `agentmemory://memories/latest` | Latest 10 active memories |
631
+ | Resource | `agentmemory://graph/stats` | Knowledge graph statistics |
632
+ | Prompt | `recall_context` | Search + return context messages |
633
+ | Prompt | `session_handoff` | Handoff data between agents |
634
+ | Prompt | `detect_patterns` | Analyze recurring patterns |
635
+ | Skill | `/recall` | Search memory |
636
+ | Skill | `/remember` | Save to long-term memory |
637
+ | Skill | `/session-history` | Recent session summaries |
638
+ | Skill | `/forget` | Delete observations/sessions |
639
+
640
+ ### Standalone MCP
641
+
642
+ Run without the full server for any MCP client. Either of these works:
607
643
 
608
644
  ```bash
609
- npx agentmemory-mcp
645
+ npx -y @agentmemory/agentmemory mcp # canonical (always available)
646
+ npx -y agentmemory-mcp # shim package alias
610
647
  ```
611
648
 
612
649
  Or add to your agent's MCP config:
613
650
 
651
+ Most agents (Cursor, Claude Desktop, Cline, etc.):
614
652
  ```json
615
653
  {
616
654
  "mcpServers": {
617
655
  "agentmemory": {
618
656
  "command": "npx",
619
- "args": ["agentmemory-mcp"]
657
+ "args": ["-y", "agentmemory-mcp"]
620
658
  }
621
659
  }
622
660
  }
623
661
  ```
624
662
 
625
- The standalone server uses in-memory KV with optional JSON persistence (`STANDALONE_PERSIST_PATH`).
626
-
627
- ### MCP Endpoints (embedded mode)
628
-
629
- ```http
630
- GET /agentmemory/mcp/tools — List available tools
631
- POST /agentmemory/mcp/call — Execute a tool
632
- GET /agentmemory/mcp/resources List available resources
633
- POST /agentmemory/mcp/resources/read — Read a resource by URI
634
- GET /agentmemory/mcp/prompts — List available prompts
635
- POST /agentmemory/mcp/prompts/get — Get a prompt with arguments
663
+ OpenCode (`opencode.json`):
664
+ ```json
665
+ {
666
+ "mcp": {
667
+ "agentmemory": {
668
+ "type": "local",
669
+ "command": ["npx", "-y", "agentmemory-mcp"],
670
+ "enabled": true
671
+ }
672
+ }
673
+ }
636
674
  ```
637
675
 
638
- ## Skills
639
-
640
- Four slash commands for interacting with memory:
676
+ ---
641
677
 
642
- | Skill | Usage |
643
- |-------|-------|
644
- | `/recall` | Search memory for past context (`/recall auth middleware`) |
645
- | `/remember` | Save something to long-term memory (`/remember always use jose for JWT`) |
646
- | `/session-history` | Show recent session summaries |
647
- | `/forget` | Delete specific observations or entire sessions |
678
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-viewer.svg"><img src="assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
648
679
 
649
- ## Real-Time Viewer
680
+ Auto-starts on port `3113`. Live observation stream, session explorer, memory browser, knowledge graph visualization, and health dashboard.
650
681
 
651
- agentmemory includes a real-time web dashboard that auto-starts on port `3113` (configurable via `III_REST_PORT + 2`).
682
+ ```bash
683
+ open http://localhost:3113
684
+ ```
652
685
 
653
- - Live observation stream via WebSocket
654
- - Session explorer with observation details
655
- - Memory browser with search and filtering
656
- - Knowledge graph visualization
657
- - Health and metrics dashboard
686
+ The viewer server binds to `127.0.0.1` by default. The REST-served `/agentmemory/viewer` endpoint follows the normal `AGENTMEMORY_SECRET` bearer-token rules. CSP headers use a per-response script nonce and disable inline handler attributes (`script-src-attr 'none'`).
658
687
 
659
- Access at `http://localhost:3113` or via `GET /agentmemory/viewer` on the API port. Protected by `AGENTMEMORY_SECRET` when set. CSP headers applied to all HTML responses.
688
+ ---
660
689
 
661
- ## Configuration
690
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-config.svg"><img src="assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
662
691
 
663
692
  ### LLM Providers
664
693
 
665
- agentmemory needs an LLM for compressing observations and generating summaries. It auto-detects from your environment.
694
+ agentmemory auto-detects from your environment. No API key needed if you have a Claude subscription.
666
695
 
667
696
  | Provider | Config | Notes |
668
697
  |----------|--------|-------|
669
- | **Claude subscription** (default) | No config needed | Uses `@anthropic-ai/claude-agent-sdk`. Zero cost beyond your Max/Pro plan |
670
- | **Anthropic API** | `ANTHROPIC_API_KEY` | Direct API access, per-token billing. Supports `ANTHROPIC_BASE_URL` for custom endpoints |
671
- | **MiniMax** | `MINIMAX_API_KEY` | Anthropic-compatible API. Default model: `MiniMax-M2.7` |
672
- | **Gemini** | `GEMINI_API_KEY` | Also enables Gemini embeddings (free tier) |
673
- | **OpenRouter** | `OPENROUTER_API_KEY` | Access any model through one API |
674
-
675
- No API key? agentmemory uses your Claude subscription automatically. Zero config.
698
+ | **Claude subscription** (default) | No config needed | Uses `@anthropic-ai/claude-agent-sdk` |
699
+ | Anthropic API | `ANTHROPIC_API_KEY` | Per-token billing |
700
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic-compatible |
701
+ | Gemini | `GEMINI_API_KEY` | Also enables embeddings |
702
+ | OpenRouter | `OPENROUTER_API_KEY` | Any model |
676
703
 
677
704
  ### Environment Variables
678
705
 
@@ -680,262 +707,106 @@ Create `~/.agentmemory/.env`:
680
707
 
681
708
  ```env
682
709
  # LLM provider (pick one, or leave empty for Claude subscription)
683
- ANTHROPIC_API_KEY=sk-ant-...
684
- # ANTHROPIC_BASE_URL=https://custom-endpoint.example.com
685
- # MINIMAX_API_KEY=...
686
- # MINIMAX_MODEL=MiniMax-M2.7
710
+ # ANTHROPIC_API_KEY=sk-ant-...
687
711
  # GEMINI_API_KEY=...
688
712
  # OPENROUTER_API_KEY=...
689
713
 
690
- # Embedding provider (auto-detected from LLM keys, or override)
691
- # EMBEDDING_PROVIDER=voyage
714
+ # Embedding provider (auto-detected, or override)
715
+ # EMBEDDING_PROVIDER=local
692
716
  # VOYAGE_API_KEY=...
693
- # OPENAI_API_KEY=...
694
- # COHERE_API_KEY=...
695
717
 
696
- # Hybrid search weights (default: 0.4 BM25 + 0.6 vector)
718
+ # Search tuning
697
719
  # BM25_WEIGHT=0.4
698
720
  # VECTOR_WEIGHT=0.6
699
-
700
- # Provider fallback chain (comma-separated, tried in order)
701
- # FALLBACK_PROVIDERS=anthropic,minimax,gemini,openrouter
702
-
703
- # Bearer token for API auth
704
- # AGENTMEMORY_SECRET=your-secret-here
705
-
706
- # Engine connection
707
- # III_ENGINE_URL=ws://localhost:49134
708
- # III_REST_PORT=3111
709
- # III_STREAMS_PORT=3112
710
- # Viewer runs on III_REST_PORT + 2 (default: 3113)
711
-
712
- # Memory tuning
713
721
  # TOKEN_BUDGET=2000
714
- # MAX_OBS_PER_SESSION=500
715
722
 
716
- # Claude Code Memory Bridge (v0.5.0)
717
- # CLAUDE_MEMORY_BRIDGE=false
718
- # CLAUDE_MEMORY_LINE_BUDGET=200
723
+ # Auth
724
+ # AGENTMEMORY_SECRET=your-secret
719
725
 
720
- # Standalone MCP Server (v0.5.0)
721
- # STANDALONE_MCP=false
722
- # STANDALONE_PERSIST_PATH=~/.agentmemory/standalone.json
726
+ # Ports (defaults: 3111 API, 3113 viewer)
727
+ # III_REST_PORT=3111
723
728
 
724
- # Knowledge Graph (v0.5.0)
729
+ # Features
725
730
  # GRAPH_EXTRACTION_ENABLED=false
726
- # GRAPH_EXTRACTION_BATCH_SIZE=10
727
-
728
- # Consolidation Pipeline (v0.5.0)
729
731
  # CONSOLIDATION_ENABLED=true
730
- # CONSOLIDATION_DECAY_DAYS=30
731
-
732
- # Lesson Decay (v0.7.0)
733
732
  # LESSON_DECAY_ENABLED=true
734
-
735
- # Obsidian Export (v0.7.0)
736
733
  # OBSIDIAN_AUTO_EXPORT=false
734
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
735
+ # CLAUDE_MEMORY_BRIDGE=false
736
+ # SNAPSHOT_ENABLED=false
737
737
 
738
- # MCP Tool Visibility (v0.7.0) — "core" (7 tools) or "all" (43 tools)
739
- # AGENTMEMORY_TOOLS=core
740
-
741
- # Team Memory (v0.5.0)
738
+ # Team
742
739
  # TEAM_ID=
743
740
  # USER_ID=
744
741
  # TEAM_MODE=private
745
742
 
746
- # Git Snapshots (v0.5.0)
747
- # SNAPSHOT_ENABLED=false
748
- # SNAPSHOT_INTERVAL=3600
749
- # SNAPSHOT_DIR=~/.agentmemory/snapshots
743
+ # Tool visibility: "core" (7 tools) or "all" (43 tools)
744
+ # AGENTMEMORY_TOOLS=core
750
745
  ```
751
746
 
752
- ## API
747
+ ---
748
+
749
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-api.svg"><img src="assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
750
+
751
+ 109 endpoints on port `3111`. The REST API binds to `127.0.0.1` by default. Protected endpoints require `Authorization: Bearer <secret>` when `AGENTMEMORY_SECRET` is set, and mesh sync endpoints require `AGENTMEMORY_SECRET` on both peers.
753
752
 
754
- 109 endpoints on port `3111` (103 core + 6 MCP protocol). Protected endpoints require `Authorization: Bearer <secret>` when `AGENTMEMORY_SECRET` is set. The table below shows a representative subset; see `src/triggers/api.ts` for the full endpoint list.
753
+ <details>
754
+ <summary>Key endpoints</summary>
755
755
 
756
756
  | Method | Path | Description |
757
757
  |--------|------|-------------|
758
- | `GET` | `/agentmemory/health` | Health check with metrics (always public) |
759
- | `GET` | `/agentmemory/livez` | Liveness probe (always public) |
758
+ | `GET` | `/agentmemory/health` | Health check (always public) |
760
759
  | `POST` | `/agentmemory/session/start` | Start session + get context |
761
- | `POST` | `/agentmemory/session/end` | Mark session complete |
760
+ | `POST` | `/agentmemory/session/end` | End session |
762
761
  | `POST` | `/agentmemory/observe` | Capture observation |
762
+ | `POST` | `/agentmemory/smart-search` | Hybrid search |
763
763
  | `POST` | `/agentmemory/context` | Generate context |
764
- | `POST` | `/agentmemory/search` | Search observations (BM25). Optional `project`/`cwd` filters |
765
- | `POST` | `/agentmemory/smart-search` | Hybrid search with progressive disclosure |
766
- | `POST` | `/agentmemory/summarize` | Generate session summary |
767
764
  | `POST` | `/agentmemory/remember` | Save to long-term memory |
768
- | `POST` | `/agentmemory/forget` | Delete observations/sessions |
769
- | `POST` | `/agentmemory/consolidate` | Merge duplicate observations |
770
- | `POST` | `/agentmemory/patterns` | Detect recurring patterns |
771
- | `POST` | `/agentmemory/generate-rules` | Generate CLAUDE.md rules from patterns |
772
- | `POST` | `/agentmemory/file-context` | Get file-specific history |
773
- | `POST` | `/agentmemory/enrich` | Unified enrichment (file context + memories + bugs) |
774
- | `POST` | `/agentmemory/evict` | Evict stale memories (`?dryRun=true`) |
775
- | `POST` | `/agentmemory/migrate` | Import from SQLite |
776
- | `POST` | `/agentmemory/timeline` | Chronological observations around anchor |
777
- | `POST` | `/agentmemory/relations` | Create memory relationship (with confidence) |
778
- | `POST` | `/agentmemory/evolve` | Evolve memory (new version) |
779
- | `POST` | `/agentmemory/auto-forget` | Run auto-forget (`?dryRun=true`) |
780
- | `POST` | `/agentmemory/import` | Import data from JSON |
781
- | `GET` | `/agentmemory/profile` | Project profile (`?project=/path`) |
782
- | `GET` | `/agentmemory/export` | Export all data as JSON |
783
- | `GET` | `/agentmemory/sessions` | List all sessions |
784
- | `GET` | `/agentmemory/observations` | Session observations (`?sessionId=X`) |
785
- | `GET` | `/agentmemory/viewer` | Real-time web viewer (also at `http://localhost:3113`) |
786
- | `GET` | `/agentmemory/claude-bridge/read` | Read Claude Code native MEMORY.md |
787
- | `POST` | `/agentmemory/claude-bridge/sync` | Sync memories to MEMORY.md |
788
- | `POST` | `/agentmemory/graph/query` | Query knowledge graph (BFS traversal) |
789
- | `GET` | `/agentmemory/graph/stats` | Knowledge graph node/edge counts |
790
- | `POST` | `/agentmemory/graph/extract` | Extract entities from observations |
791
- | `POST` | `/agentmemory/consolidate-pipeline` | Run 4-tier consolidation pipeline |
792
- | `POST` | `/agentmemory/team/share` | Share memory with team members |
793
- | `GET` | `/agentmemory/team/feed` | Recent shared items from team |
794
- | `GET` | `/agentmemory/team/profile` | Aggregated team memory profile |
795
- | `GET` | `/agentmemory/audit` | Query audit trail (`?operation=X&limit=N`) |
796
- | `DELETE` | `/agentmemory/governance/memories` | Delete specific memories with audit |
797
- | `POST` | `/agentmemory/governance/bulk-delete` | Bulk delete by type/date/quality |
798
- | `GET` | `/agentmemory/snapshots` | List git snapshots |
799
- | `POST` | `/agentmemory/snapshot/create` | Create git-versioned snapshot |
800
- | `POST` | `/agentmemory/snapshot/restore` | Restore from snapshot commit |
801
- | `POST` | `/agentmemory/lessons` | Save a lesson (returns 201 if created, 200 if strengthened) |
802
- | `GET` | `/agentmemory/lessons` | List lessons (`?project=X&minConfidence=0.5`) |
803
- | `POST` | `/agentmemory/lessons/search` | Search lessons by query |
804
- | `POST` | `/agentmemory/lessons/strengthen` | Reinforce a lesson's confidence |
805
- | `POST` | `/agentmemory/obsidian/export` | Export vault as Obsidian Markdown |
806
- | `GET` | `/agentmemory/mcp/tools` | List MCP tools |
807
- | `POST` | `/agentmemory/mcp/call` | Execute MCP tool |
808
- | `GET` | `/agentmemory/mcp/resources` | List MCP resources |
809
- | `POST` | `/agentmemory/mcp/resources/read` | Read MCP resource by URI |
810
- | `GET` | `/agentmemory/mcp/prompts` | List MCP prompts |
811
- | `POST` | `/agentmemory/mcp/prompts/get` | Get MCP prompt with arguments |
812
-
813
- ## Plugin Install
814
-
815
- ### From Marketplace (recommended)
765
+ | `POST` | `/agentmemory/forget` | Delete observations |
766
+ | `POST` | `/agentmemory/enrich` | File context + memories + bugs |
767
+ | `GET` | `/agentmemory/profile` | Project profile |
768
+ | `GET` | `/agentmemory/export` | Export all data |
769
+ | `POST` | `/agentmemory/import` | Import from JSON |
770
+ | `POST` | `/agentmemory/graph/query` | Knowledge graph query |
771
+ | `POST` | `/agentmemory/team/share` | Share with team |
772
+ | `GET` | `/agentmemory/audit` | Audit trail |
816
773
 
817
- ```bash
818
- /plugin marketplace add rohitg00/agentmemory
819
- /plugin install agentmemory
820
- ```
774
+ Full endpoint list: [`src/triggers/api.ts`](src/triggers/api.ts)
821
775
 
822
- Restart Claude Code. All 12 hooks, 4 skills, and 43 MCP tools are registered automatically.
776
+ </details>
823
777
 
824
- ### Plugin Commands
778
+ ---
825
779
 
826
- ```bash
827
- /plugin install agentmemory # Install
828
- /plugin disable agentmemory # Disable without uninstalling
829
- /plugin enable agentmemory # Re-enable
830
- /plugin uninstall agentmemory # Remove
831
- ```
780
+ <h2 id="architecture"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-architecture.svg"><img src="assets/tags/section-architecture.svg" alt="Architecture" height="32" /></picture></h2>
781
+
782
+ Built on [iii-engine](https://iii.dev)'s three primitives — no Express, no Postgres, no Redis.
832
783
 
833
- ## Architecture
784
+ **118 source files · ~21,800 LOC · 646 tests · 123 functions · 34 KV scopes**
834
785
 
835
- agentmemory is built on iii-engine's three primitives:
786
+ <details>
787
+ <summary>What iii-engine replaces</summary>
836
788
 
837
- | What you'd normally need | What agentmemory uses |
789
+ | Traditional stack | agentmemory uses |
838
790
  |---|---|
839
791
  | Express.js / Fastify | iii HTTP Triggers |
840
792
  | SQLite / Postgres + pgvector | iii KV State + in-memory vector index |
841
793
  | SSE / Socket.io | iii Streams (WebSocket) |
842
794
  | pm2 / systemd | iii-engine worker management |
843
- | Prometheus / Grafana | iii OTEL + built-in health monitor |
844
- | Redis (circuit breaker) | In-process circuit breaker + fallback chain |
845
-
846
- **118 source files. ~21,800 LOC. 646 tests. Zero external DB dependencies.**
847
-
848
- ### Functions (123 mem:: functions)
849
-
850
- | Category | Functions | Purpose |
851
- |----------|-----------|---------|
852
- | **Core Memory** | `observe`, `compress`, `search`, `smart-search` | Capture, compress, and search observations |
853
- | | `context`, `summarize`, `remember`, `forget` | Build context, generate summaries, save/delete memories |
854
- | | `file-context`, `enrich`, `patterns`, `generate-rules` | File history, enrichment, pattern detection, rule generation |
855
- | | `migrate`, `export`, `import` | SQLite migration, JSON round-trip (v0.3.0–v0.7.2) |
856
- | **Search** | `expand-query`, `sliding-window`, `graph-retrieval` | Query reformulations, context enrichment, entity-based retrieval |
857
- | | `retention-score`, `retention-evict` | Ebbinghaus decay with tiered storage (hot/warm/cold) |
858
- | **Memory Evolution** | `evolve`, `auto-forget`, `evict` | Version memories, TTL expiry, importance-based eviction |
859
- | | `consolidate`, `consolidate-pipeline` | Merge duplicates, 4-tier consolidation (working→episodic→semantic→procedural) |
860
- | | `verify`, `cascade-update` | Citation chain provenance, staleness propagation |
861
- | **Knowledge Graph** | `graph-extract`, `graph-query`, `graph-stats` | LLM entity extraction, BFS traversal, statistics |
862
- | | `temporal-graph-extract`, `temporal-query` | Temporal knowledge extraction + point-in-time queries |
863
- | **Relationships** | `relate`, `get-related`, `timeline`, `profile` | Memory relations, chronological view, project profiles |
864
- | **Claude Bridge** | `claude-bridge-read`, `claude-bridge-sync` | Bi-directional sync with MEMORY.md |
865
- | **Actions** | `action-create`, `action-update`, `action-get`, `action-list` | Dependency-aware work items with typed edges |
866
- | | `action-edge-create` | Create typed edges between actions (requires, unlocks, gated_by) |
867
- | | `frontier`, `next` | Priority-ranked unblocked action queue |
868
- | **Leases** | `lease-acquire`, `lease-release`, `lease-renew`, `lease-cleanup` | TTL-based atomic agent claims with auto-cleanup |
869
- | **Routines** | `routine-create`, `routine-freeze`, `routine-list`, `routine-run`, `routine-status` | Frozen workflow templates instantiated into action chains |
870
- | **Signals** | `signal-send`, `signal-read`, `signal-threads`, `signal-cleanup` | Threaded inter-agent messaging with read receipts |
871
- | **Checkpoints** | `checkpoint-create`, `checkpoint-resolve`, `checkpoint-list`, `checkpoint-expire` | External condition gates (CI, approval, deploy) |
872
- | **Mesh** | `mesh-register`, `mesh-sync`, `mesh-receive`, `mesh-list`, `mesh-remove` | P2P sync between agentmemory instances |
873
- | **Sentinels** | `sentinel-create`, `sentinel-trigger`, `sentinel-check`, `sentinel-cancel`, `sentinel-list`, `sentinel-expire` | Event-driven condition watchers |
874
- | **Sketches** | `sketch-create`, `sketch-add`, `sketch-promote`, `sketch-discard`, `sketch-list`, `sketch-gc` | Ephemeral action graphs with auto-expiry |
875
- | **Crystals** | `crystallize`, `auto-crystallize`, `crystal-list`, `crystal-get` | LLM-powered compaction of action chains into digests |
876
- | **Lessons** | `lesson-save`, `lesson-recall`, `lesson-list`, `lesson-strengthen`, `lesson-decay-sweep` | Confidence-scored lessons with dedup, reinforcement, and decay |
877
- | **Facets** | `facet-tag`, `facet-untag`, `facet-query`, `facet-get`, `facet-stats`, `facet-dimensions` | Multi-dimensional tagging with AND/OR queries |
878
- | **Diagnostics** | `diagnose`, `heal` | Self-diagnosis across 8 categories with auto-fix |
879
- | **Flow** | `flow-compress` | LLM summarization of completed action chains |
880
- | **Branch** | `detect-worktree`, `list-worktrees`, `branch-sessions` | Git worktree detection for shared memory |
881
- | **Team** | `team-share`, `team-feed`, `team-profile` | Namespaced shared + private team memory |
882
- | **Governance** | `governance-delete`, `governance-bulk`, `audit-query` | Delete with audit trail, bulk operations |
883
- | **Snapshots** | `snapshot-create`, `snapshot-list`, `snapshot-restore` | Git-versioned memory state |
884
- | **Export** | `obsidian-export` | Obsidian-compatible Markdown with YAML frontmatter + wikilinks |
885
-
886
- ### Data Model (34 KV scopes)
887
-
888
- | Scope | Stores |
889
- |-------|--------|
890
- | `mem:sessions` | Session metadata, project, timestamps |
891
- | `mem:obs:{session_id}` | Compressed observations with embeddings |
892
- | `mem:summaries` | End-of-session summaries |
893
- | `mem:memories` | Long-term memories (versioned, with relationships) |
894
- | `mem:relations` | Memory relationship graph |
895
- | `mem:profiles` | Aggregated project profiles |
896
- | `mem:emb:{obs_id}` | Vector embeddings |
897
- | `mem:index:bm25` | Persisted BM25 index |
898
- | `mem:metrics` | Per-function metrics |
899
- | `mem:health` | Health snapshots |
900
- | `mem:config` | Runtime configuration overrides |
901
- | `mem:confidence` | Confidence scores for memories |
902
- | `mem:claude-bridge` | Claude Code MEMORY.md bridge state |
903
- | `mem:graph:nodes` | Knowledge graph entities |
904
- | `mem:graph:edges` | Knowledge graph relationships |
905
- | `mem:semantic` | Semantic memories (consolidated facts) |
906
- | `mem:procedural` | Procedural memories (extracted workflows) |
907
- | `mem:team:{id}:shared` | Team shared items |
908
- | `mem:team:{id}:users:{uid}` | Per-user team state |
909
- | `mem:team:{id}:profile` | Aggregated team profile |
910
- | `mem:audit` | Audit trail for all operations |
911
- | `mem:actions` | Dependency-aware work items |
912
- | `mem:action-edges` | Typed edges (requires, unlocks, gated_by, etc.) |
913
- | `mem:leases` | TTL-based agent work claims |
914
- | `mem:routines` | Frozen workflow templates |
915
- | `mem:routine-runs` | Instantiated routine execution tracking |
916
- | `mem:signals` | Inter-agent messages with threading |
917
- | `mem:checkpoints` | External condition gates |
918
- | `mem:mesh` | Registered P2P sync peers |
919
- | `mem:sentinels` | Event-driven condition watchers |
920
- | `mem:sketches` | Ephemeral action graphs |
921
- | `mem:crystals` | Compacted action chain digests |
922
- | `mem:facets` | Multi-dimensional tags |
923
- | `mem:lessons` | Confidence-scored lessons with decay |
924
-
925
- ## Development
795
+ | Prometheus / Grafana | iii OTEL + health monitor |
796
+
797
+ </details>
798
+
799
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-development.svg"><img src="assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
926
800
 
927
801
  ```bash
928
802
  npm run dev # Hot reload
929
- npm run build # Production build (~425KB)
930
- npm test # Unit tests (646 tests, ~1.7s)
803
+ npm run build # Production build
804
+ npm test # 646 tests (~1.7s)
931
805
  npm run test:integration # API tests (requires running services)
932
806
  ```
933
807
 
934
- ### Prerequisites
935
-
936
- - Node.js >= 20
937
- - [iii-engine](https://iii.dev/docs) (`curl -fsSL https://install.iii.dev/iii/main/install.sh | sh`)
808
+ **Prerequisites:** Node.js >= 20, [iii-engine](https://iii.dev/docs) or Docker
938
809
 
939
- ## License
810
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-license.svg"><img src="assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
940
811
 
941
812
  [Apache-2.0](LICENSE)