ziiagentmemory 0.1.0

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.
Files changed (160) hide show
  1. package/.env.example +175 -0
  2. package/AGENTS.md +124 -0
  3. package/LICENSE +190 -0
  4. package/README.md +1546 -0
  5. package/dist/cli.d.mts +5 -0
  6. package/dist/cli.d.mts.map +1 -0
  7. package/dist/cli.mjs +2859 -0
  8. package/dist/cli.mjs.map +1 -0
  9. package/dist/config-ChC9EtgV.mjs +259 -0
  10. package/dist/config-ChC9EtgV.mjs.map +1 -0
  11. package/dist/connect-JnsJXc68.mjs +1075 -0
  12. package/dist/connect-JnsJXc68.mjs.map +1 -0
  13. package/dist/hooks/notification.d.mts +1 -0
  14. package/dist/hooks/notification.mjs +74 -0
  15. package/dist/hooks/notification.mjs.map +1 -0
  16. package/dist/hooks/post-commit.d.mts +1 -0
  17. package/dist/hooks/post-commit.mjs +101 -0
  18. package/dist/hooks/post-commit.mjs.map +1 -0
  19. package/dist/hooks/post-tool-failure.d.mts +1 -0
  20. package/dist/hooks/post-tool-failure.mjs +75 -0
  21. package/dist/hooks/post-tool-failure.mjs.map +1 -0
  22. package/dist/hooks/post-tool-use.d.mts +1 -0
  23. package/dist/hooks/post-tool-use.mjs +120 -0
  24. package/dist/hooks/post-tool-use.mjs.map +1 -0
  25. package/dist/hooks/pre-compact.d.mts +1 -0
  26. package/dist/hooks/pre-compact.mjs +78 -0
  27. package/dist/hooks/pre-compact.mjs.map +1 -0
  28. package/dist/hooks/pre-tool-use.d.mts +1 -0
  29. package/dist/hooks/pre-tool-use.mjs +84 -0
  30. package/dist/hooks/pre-tool-use.mjs.map +1 -0
  31. package/dist/hooks/prompt-submit.d.mts +1 -0
  32. package/dist/hooks/prompt-submit.mjs +67 -0
  33. package/dist/hooks/prompt-submit.mjs.map +1 -0
  34. package/dist/hooks/session-end.d.mts +1 -0
  35. package/dist/hooks/session-end.mjs +60 -0
  36. package/dist/hooks/session-end.mjs.map +1 -0
  37. package/dist/hooks/session-start.d.mts +1 -0
  38. package/dist/hooks/session-start.mjs +85 -0
  39. package/dist/hooks/session-start.mjs.map +1 -0
  40. package/dist/hooks/stop.d.mts +1 -0
  41. package/dist/hooks/stop.mjs +44 -0
  42. package/dist/hooks/stop.mjs.map +1 -0
  43. package/dist/hooks/subagent-start.d.mts +1 -0
  44. package/dist/hooks/subagent-start.mjs +73 -0
  45. package/dist/hooks/subagent-start.mjs.map +1 -0
  46. package/dist/hooks/subagent-stop.d.mts +1 -0
  47. package/dist/hooks/subagent-stop.mjs +74 -0
  48. package/dist/hooks/subagent-stop.mjs.map +1 -0
  49. package/dist/hooks/task-completed.d.mts +1 -0
  50. package/dist/hooks/task-completed.mjs +73 -0
  51. package/dist/hooks/task-completed.mjs.map +1 -0
  52. package/dist/image-refs-BKLmp_sD.mjs +34 -0
  53. package/dist/image-refs-BKLmp_sD.mjs.map +1 -0
  54. package/dist/image-refs-C2YU7BIm.mjs +34 -0
  55. package/dist/image-refs-C2YU7BIm.mjs.map +1 -0
  56. package/dist/index.d.mts +2 -0
  57. package/dist/index.mjs +22324 -0
  58. package/dist/index.mjs.map +1 -0
  59. package/dist/keyed-mutex-DTHtcZrt.mjs +88 -0
  60. package/dist/keyed-mutex-DTHtcZrt.mjs.map +1 -0
  61. package/dist/logger-BEB7pCI9.mjs +43 -0
  62. package/dist/logger-BEB7pCI9.mjs.map +1 -0
  63. package/dist/schema-CNiCWzV9.mjs +78 -0
  64. package/dist/schema-CNiCWzV9.mjs.map +1 -0
  65. package/dist/src-Cr3pH_uH.mjs +20745 -0
  66. package/dist/src-Cr3pH_uH.mjs.map +1 -0
  67. package/dist/standalone-C6KzNkt5.mjs +700 -0
  68. package/dist/standalone-C6KzNkt5.mjs.map +1 -0
  69. package/dist/standalone.d.mts +25 -0
  70. package/dist/standalone.d.mts.map +1 -0
  71. package/dist/standalone.mjs +1867 -0
  72. package/dist/standalone.mjs.map +1 -0
  73. package/dist/tools-registry-DCt2KAWA.mjs +1145 -0
  74. package/dist/tools-registry-DCt2KAWA.mjs.map +1 -0
  75. package/docker-compose.yml +47 -0
  76. package/iii-config.docker.yaml +53 -0
  77. package/iii-config.yaml +61 -0
  78. package/package.json +99 -0
  79. package/plugin/.claude-plugin/plugin.json +13 -0
  80. package/plugin/.codex-plugin/plugin.json +15 -0
  81. package/plugin/.mcp.copilot.json +15 -0
  82. package/plugin/.mcp.json +13 -0
  83. package/plugin/hooks/hooks.codex.json +67 -0
  84. package/plugin/hooks/hooks.copilot.json +72 -0
  85. package/plugin/hooks/hooks.json +125 -0
  86. package/plugin/opencode/README.md +229 -0
  87. package/plugin/opencode/agentmemory-capture.ts +687 -0
  88. package/plugin/opencode/commands/recall.md +19 -0
  89. package/plugin/opencode/commands/remember.md +19 -0
  90. package/plugin/opencode/plugin.json +12 -0
  91. package/plugin/plugin.json +15 -0
  92. package/plugin/scripts/diagnostics.mjs +551 -0
  93. package/plugin/scripts/notification.d.mts +1 -0
  94. package/plugin/scripts/notification.mjs +74 -0
  95. package/plugin/scripts/notification.mjs.map +1 -0
  96. package/plugin/scripts/post-commit.d.mts +1 -0
  97. package/plugin/scripts/post-commit.mjs +101 -0
  98. package/plugin/scripts/post-commit.mjs.map +1 -0
  99. package/plugin/scripts/post-tool-failure.d.mts +1 -0
  100. package/plugin/scripts/post-tool-failure.mjs +75 -0
  101. package/plugin/scripts/post-tool-failure.mjs.map +1 -0
  102. package/plugin/scripts/post-tool-use.d.mts +1 -0
  103. package/plugin/scripts/post-tool-use.mjs +120 -0
  104. package/plugin/scripts/post-tool-use.mjs.map +1 -0
  105. package/plugin/scripts/pre-compact.d.mts +1 -0
  106. package/plugin/scripts/pre-compact.mjs +78 -0
  107. package/plugin/scripts/pre-compact.mjs.map +1 -0
  108. package/plugin/scripts/pre-tool-use.d.mts +1 -0
  109. package/plugin/scripts/pre-tool-use.mjs +84 -0
  110. package/plugin/scripts/pre-tool-use.mjs.map +1 -0
  111. package/plugin/scripts/prompt-submit.d.mts +1 -0
  112. package/plugin/scripts/prompt-submit.mjs +67 -0
  113. package/plugin/scripts/prompt-submit.mjs.map +1 -0
  114. package/plugin/scripts/session-end.d.mts +1 -0
  115. package/plugin/scripts/session-end.mjs +60 -0
  116. package/plugin/scripts/session-end.mjs.map +1 -0
  117. package/plugin/scripts/session-start.d.mts +1 -0
  118. package/plugin/scripts/session-start.mjs +85 -0
  119. package/plugin/scripts/session-start.mjs.map +1 -0
  120. package/plugin/scripts/stop.d.mts +1 -0
  121. package/plugin/scripts/stop.mjs +44 -0
  122. package/plugin/scripts/stop.mjs.map +1 -0
  123. package/plugin/scripts/subagent-start.d.mts +1 -0
  124. package/plugin/scripts/subagent-start.mjs +73 -0
  125. package/plugin/scripts/subagent-start.mjs.map +1 -0
  126. package/plugin/scripts/subagent-stop.d.mts +1 -0
  127. package/plugin/scripts/subagent-stop.mjs +74 -0
  128. package/plugin/scripts/subagent-stop.mjs.map +1 -0
  129. package/plugin/scripts/task-completed.d.mts +1 -0
  130. package/plugin/scripts/task-completed.mjs +73 -0
  131. package/plugin/scripts/task-completed.mjs.map +1 -0
  132. package/plugin/skills/_shared/TROUBLESHOOTING.md +38 -0
  133. package/plugin/skills/agentmemory-agents/REFERENCE.md +28 -0
  134. package/plugin/skills/agentmemory-agents/SKILL.md +34 -0
  135. package/plugin/skills/agentmemory-architecture/SKILL.md +33 -0
  136. package/plugin/skills/agentmemory-config/REFERENCE.md +42 -0
  137. package/plugin/skills/agentmemory-config/SKILL.md +37 -0
  138. package/plugin/skills/agentmemory-hooks/REFERENCE.md +20 -0
  139. package/plugin/skills/agentmemory-hooks/SKILL.md +39 -0
  140. package/plugin/skills/agentmemory-mcp-tools/REFERENCE.md +65 -0
  141. package/plugin/skills/agentmemory-mcp-tools/SKILL.md +39 -0
  142. package/plugin/skills/agentmemory-rest-api/REFERENCE.md +129 -0
  143. package/plugin/skills/agentmemory-rest-api/SKILL.md +43 -0
  144. package/plugin/skills/commit-context/EXAMPLES.md +71 -0
  145. package/plugin/skills/commit-context/SKILL.md +64 -0
  146. package/plugin/skills/commit-history/EXAMPLES.md +71 -0
  147. package/plugin/skills/commit-history/SKILL.md +62 -0
  148. package/plugin/skills/forget/EXAMPLES.md +75 -0
  149. package/plugin/skills/forget/SKILL.md +66 -0
  150. package/plugin/skills/handoff/EXAMPLES.md +56 -0
  151. package/plugin/skills/handoff/SKILL.md +68 -0
  152. package/plugin/skills/recall/EXAMPLES.md +74 -0
  153. package/plugin/skills/recall/SKILL.md +60 -0
  154. package/plugin/skills/recap/EXAMPLES.md +60 -0
  155. package/plugin/skills/recap/SKILL.md +63 -0
  156. package/plugin/skills/remember/EXAMPLES.md +67 -0
  157. package/plugin/skills/remember/SKILL.md +61 -0
  158. package/plugin/skills/session-history/EXAMPLES.md +59 -0
  159. package/plugin/skills/session-history/SKILL.md +61 -0
  160. package/plugin/skills/write-agentmemory-skill/SKILL.md +40 -0
package/README.md ADDED
@@ -0,0 +1,1546 @@
1
+ <p align="center">
2
+ <img src="assets/banner.png" alt="agentmemory — Persistent memory for AI coding agents" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ Your coding agent remembers everything. No more re-explaining.
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Persistent memory for Claude Code, GitHub Copilot CLI, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode, and any MCP client.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="README.md">English</a> |
15
+ <a href="READMEs/README.zh-CN.md">简体中文</a> |
16
+ <a href="READMEs/README.zh-TW.md">繁體中文</a> |
17
+ <a href="READMEs/README.ja-JP.md">日本語</a> |
18
+ <a href="READMEs/README.ko-KR.md">한국어</a> |
19
+ <a href="READMEs/README.es-ES.md">Español</a> |
20
+ <a href="READMEs/README.tr-TR.md">Türkçe</a> |
21
+ <a href="READMEs/README.ru-RU.md">Русский</a> |
22
+ <a href="READMEs/README.hi-IN.md">हिन्दी</a> |
23
+ <a href="READMEs/README.pt-BR.md">Português</a> |
24
+ <a href="READMEs/README.fr-FR.md">Français</a> |
25
+ <a href="READMEs/README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1.3k%20stars%20%2F%20182%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1.3k stars / 182 forks on the gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>The gist extends Karpathy's LLM Wiki pattern with confidence scoring, lifecycle, knowledge graphs, and hybrid search: agentmemory is the implementation.</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <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>
52
+ <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>
53
+ <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>
54
+ <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>
55
+ </p>
56
+
57
+ <p align="center">
58
+ <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>
59
+ <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>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tools.svg"><img src="assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
61
+ <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>
62
+ <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>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tests.svg"><img src="assets/tags/stat-tests.svg" alt="1,423+ tests passing" height="38" /></picture>
64
+ </p>
65
+
66
+ <p align="center">
67
+ <img src="assets/demo.gif" alt="agentmemory demo" width="720" />
68
+ </p>
69
+
70
+ <p align="center">
71
+ <a href="#install">Install</a> &bull;
72
+ <a href="#quick-start">Quick Start</a> &bull;
73
+ <a href="#benchmarks">Benchmarks</a> &bull;
74
+ <a href="#vs-competitors">vs Competitors</a> &bull;
75
+ <a href="#works-with-every-agent">Agents</a> &bull;
76
+ <a href="#how-it-works">How It Works</a> &bull;
77
+ <a href="#mcp-server">MCP</a> &bull;
78
+ <a href="#real-time-viewer">Viewer</a> &bull;
79
+ <a href="#iii-console">iii Console</a> &bull;
80
+ <a href="#powered-by-iii">Powered by iii</a> &bull;
81
+ <a href="#configuration">Config</a> &bull;
82
+ <a href="#api">API</a>
83
+ </p>
84
+
85
+ ---
86
+
87
+ ## Install
88
+
89
+ Fastest path if you use a coding agent: hand it this one instruction and it installs, wires, and verifies agentmemory end to end.
90
+
91
+ > Retrieve and follow the instructions at: https://raw.githubusercontent.com/rohitg00/agentmemory/main/INSTALL_FOR_AGENTS.md
92
+
93
+ On Windows the fast path is WSL2. Native Windows engine setup is manual (about 10 to 20 minutes) and `agentmemory connect` is currently unsupported there. See the [Windows notes](#windows) below for the step-by-step.
94
+
95
+ ```bash
96
+ npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
97
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
98
+ # sudo npm install -g @agentmemory/agentmemory
99
+ agentmemory # start the memory server on :3111
100
+ agentmemory demo # seed sample sessions + prove recall
101
+ agentmemory demo --serve # one command: boot server, run demo, tear down (no second terminal)
102
+ agentmemory connect claude-code # wire MCP into your agent (also: copilot-cli, codex, cursor, gemini-cli, ...)
103
+ npx skills add rohitg00/agentmemory -y # install 15 native skills (8 you can invoke, 7 reference) so your agent knows when to use the tools
104
+ ```
105
+
106
+ Or via `npx` (no install):
107
+
108
+ ```bash
109
+ npx @agentmemory/agentmemory
110
+ ```
111
+
112
+ Heads-up — npx caches per version. If a bare `npx @agentmemory/agentmemory` serves an older release, force the latest with `npx -y @agentmemory/agentmemory@latest`, or clear the cache once with `rm -rf ~/.npm/_npx` (macOS/Linux; on Windows delete `%LOCALAPPDATA%\npm-cache\_npx`). The first npx run from v0.9.16+ prompts to install globally inline so the bare `agentmemory` command works everywhere afterwards.
113
+
114
+ Already running your own `iii` engine? agentmemory pins iii-engine v0.11.2 and won't attach to a different version (the worker can't speak another engine's protocol). Stop the other engine, then run `npx -y @agentmemory/agentmemory@latest` — it installs and runs the pinned v0.11.2 in `~/.agentmemory/bin`, leaving your own `iii` untouched.
115
+
116
+ Full options at [Quick Start](#quick-start) below. Agent-specific wiring at [Works with every agent](#works-with-every-agent).
117
+
118
+ ---
119
+
120
+ <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>
121
+
122
+ agentmemory works with any agent that supports hooks, MCP, or REST API. All agents share the same memory server.
123
+
124
+ <table>
125
+ <tr>
126
+ <td align="center" width="12.5%">
127
+ <a href="https://claude.com/product/claude-code"><img src="https://github.com/anthropics.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
128
+ <strong>Claude Code</strong><br/>
129
+ <sub>native plugin + 12 hooks + MCP</sub>
130
+ </td>
131
+ <td align="center" width="12.5%">
132
+ <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/>
133
+ <strong>Codex CLI</strong><br/>
134
+ <sub>native plugin + 6 hooks + MCP</sub>
135
+ </td>
136
+ <td align="center" width="12.5%">
137
+ <a href="https://github.com/features/copilot"><img src="https://github.githubassets.com/images/modules/site/copilot/copilot.png" alt="GitHub Copilot CLI" width="48" height="48" /></a><br/>
138
+ <strong>GitHub Copilot CLI</strong><br/>
139
+ <sub>MCP + plugin hooks/skills</sub>
140
+ </td>
141
+ <td align="center" width="12.5%">
142
+ <a href="integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
143
+ <strong>OpenClaw</strong><br/>
144
+ <sub>native plugin + MCP</sub>
145
+ </td>
146
+ <td align="center" width="12.5%">
147
+ <a href="integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
148
+ <strong>Hermes</strong><br/>
149
+ <sub>native plugin + MCP</sub>
150
+ </td>
151
+ <td align="center" width="12.5%">
152
+ <a href="integrations/pi/"><img src="assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
153
+ <strong>pi</strong><br/>
154
+ <sub>native plugin + MCP</sub>
155
+ </td>
156
+ <td align="center" width="12.5%">
157
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
158
+ <strong>OpenHuman</strong><br/>
159
+ <sub>native Memory trait backend</sub>
160
+ </td>
161
+ <td align="center" width="12.5%">
162
+ <a href="https://cursor.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://svgl.app/library/cursor_dark.svg"><img src="https://svgl.app/library/cursor_light.svg" alt="Cursor" width="48" height="48" /></picture></a><br/>
163
+ <strong>Cursor</strong><br/>
164
+ <sub>MCP server</sub>
165
+ </td>
166
+ <td align="center" width="12.5%">
167
+ <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/>
168
+ <strong>Gemini CLI</strong><br/>
169
+ <sub>MCP server</sub>
170
+ </td>
171
+ </tr>
172
+ <tr>
173
+ <td align="center" width="12.5%">
174
+ <a href="https://github.com/opencode-ai/opencode"><picture><source media="(prefers-color-scheme: dark)" srcset="https://svgl.app/library/opencode-dark.svg"><img src="https://svgl.app/library/opencode.svg" alt="OpenCode" width="48" height="48" /></picture></a><br/>
175
+ <strong>OpenCode</strong><br/>
176
+ <sub>22 hooks + MCP + plugin</sub>
177
+ </td>
178
+ <td align="center" width="12.5%">
179
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
180
+ <strong>Cline</strong><br/>
181
+ <sub>MCP server</sub>
182
+ </td>
183
+ <td align="center" width="12.5%">
184
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
185
+ <strong>Goose</strong><br/>
186
+ <sub>MCP server</sub>
187
+ </td>
188
+ <td align="center" width="12.5%">
189
+ <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/>
190
+ <strong>Kilo Code</strong><br/>
191
+ <sub>MCP server</sub>
192
+ </td>
193
+ <td align="center" width="12.5%">
194
+ <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/>
195
+ <strong>Aider</strong><br/>
196
+ <sub>REST API</sub>
197
+ </td>
198
+ <td align="center" width="12.5%">
199
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
200
+ <strong>Claude Desktop</strong><br/>
201
+ <sub>MCP server</sub>
202
+ </td>
203
+ <td align="center" width="12.5%">
204
+ <a href="https://windsurf.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://svgl.app/library/windsurf-dark.svg"><img src="https://svgl.app/library/windsurf-light.svg" alt="Windsurf" width="48" height="48" /></picture></a><br/>
205
+ <strong>Windsurf</strong><br/>
206
+ <sub>MCP server</sub>
207
+ </td>
208
+ <td align="center" width="12.5%">
209
+ <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/>
210
+ <strong>Roo Code</strong><br/>
211
+ <sub>MCP server</sub>
212
+ </td>
213
+ </tr>
214
+ <tr>
215
+ <td align="center" width="12.5%">
216
+ <a href="https://www.warp.dev"><img src="https://github.com/warpdotdev.png?size=120" alt="Warp" width="48" height="48" /></a><br/>
217
+ <strong>Warp</strong><br/>
218
+ <sub>connect + MCP + skills</sub>
219
+ </td>
220
+ </tr>
221
+ </table>
222
+
223
+ <p align="center">
224
+ <sub>Works with <strong>any</strong> agent that speaks MCP or HTTP. One server, memories shared across all of them.</sub>
225
+ </p>
226
+
227
+ ---
228
+
229
+ 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.
230
+
231
+ **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*.
232
+
233
+ ```bash
234
+ npx @agentmemory/agentmemory
235
+ ```
236
+
237
+ Latest release notes: [CHANGELOG.md](CHANGELOG.md).
238
+
239
+ ---
240
+
241
+ <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>
242
+
243
+ <table>
244
+ <tr>
245
+ <td width="50%">
246
+
247
+ ### Retrieval Accuracy
248
+
249
+ **coding-agent-life-v1** (in-house corpus, sandbox-reproducible)
250
+
251
+ | Adapter | P@5 | R@5 | Top-5 hit rate | p50 latency |
252
+ |---|---|---|---|---|
253
+ | **agentmemory hybrid** | **0.240** | **1.000** | **15 / 15** | 14 ms |
254
+ | grep baseline | 0.227 | 0.967 | 15 / 15 | 0 ms |
255
+
256
+ 100% top-5 hit rate at the **P@5 math ceiling** for this corpus (0.240, see scorecard). Hybrid retrieves every gold session; grep misses 1 of 2 gold on the multi-session temporal query. Lift is **recall + temporal**, not aggregate precision — this benchmark is small + gold-sparse, the larger LongMemEval-S below differentiates better. Full per-type breakdown + correction note: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
257
+
258
+ **LongMemEval-S** (ICLR 2025, 500 questions)
259
+
260
+ | System | R@5 | R@10 | MRR |
261
+ |---|---|---|---|
262
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
263
+ | BM25-only fallback | 86.2% | 94.6% | 71.5% |
264
+
265
+ </td>
266
+ <td width="50%">
267
+
268
+ ### Token Savings
269
+
270
+ | Approach | Tokens/yr | Cost/yr |
271
+ |---|---|---|
272
+ | Paste full context | 19.5M+ | Impossible (exceeds window) |
273
+ | LLM-summarized | ~650K | ~$500 |
274
+ | **agentmemory** | **~170K** | **~$10** |
275
+ | agentmemory + local embeddings | ~170K | **$0** |
276
+
277
+ </td>
278
+ </tr>
279
+ </table>
280
+
281
+ > 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) covering agentmemory vs mem0, Letta, Khoj, supermemory, MemPalace, Hippo.
282
+
283
+ **Reproduce locally:** [`eval/README.md`](eval/README.md) — adapter-pluggable harness for LongMemEval `_s` (public 500-Q) + `coding-agent-life-v1` (in-house 15-session corpus). Grep / vector / agentmemory adapters score side-by-side, NDJSON output, published scorecards land in [`docs/benchmarks/`](docs/benchmarks/).
284
+
285
+ **Pairs with [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything), and [Graphify](https://github.com/safishamsi/graphify).** Code-graph indexing, multi-agent build pipelines, and broader knowledge graphs across docs / PDFs / images / videos. agentmemory remembers the work; those three projects light up the rest of the context layer. Recipes + question-routing table: [`docs/recipes/pairings.md`](docs/recipes/pairings.md).
286
+
287
+ ---
288
+
289
+ <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>
290
+
291
+ <table>
292
+ <tr>
293
+ <th></th>
294
+ <th>agentmemory</th>
295
+ <th>mem0 (58K ⭐)</th>
296
+ <th>Letta / MemGPT (23K ⭐)</th>
297
+ <th>Khoj (35K ⭐)</th>
298
+ <th>supermemory (26K ⭐)</th>
299
+ <th>MemPalace (54K ⭐)</th>
300
+ <th>oracleagentmemory</th>
301
+ <th>Hippo</th>
302
+ <th>Built-in (CLAUDE.md)</th>
303
+ </tr>
304
+ <tr>
305
+ <td><strong>Type</strong></td>
306
+ <td>Memory engine + MCP server</td>
307
+ <td>Memory layer API</td>
308
+ <td>Full agent runtime</td>
309
+ <td>Personal AI</td>
310
+ <td>Memory API + app</td>
311
+ <td>Vector memory (OSS)</td>
312
+ <td>Memory engine (Oracle DB)</td>
313
+ <td>Memory system</td>
314
+ <td>Static file</td>
315
+ </tr>
316
+ <tr>
317
+ <td><strong>Retrieval R@5</strong></td>
318
+ <td><strong>95.2%</strong></td>
319
+ <td>68.5% (LoCoMo)</td>
320
+ <td>83.2% (LoCoMo)</td>
321
+ <td>N/A</td>
322
+ <td>Self-reported</td>
323
+ <td>~96.6% (self-reported)</td>
324
+ <td>94.4% (self-reported)</td>
325
+ <td>N/A</td>
326
+ <td>N/A (grep)</td>
327
+ </tr>
328
+ <tr>
329
+ <td><strong>Auto-capture</strong></td>
330
+ <td>12 hooks (zero manual effort)</td>
331
+ <td>Manual <code>add()</code> calls</td>
332
+ <td>Agent self-edits</td>
333
+ <td>Manual</td>
334
+ <td>API-side extraction</td>
335
+ <td>Manual</td>
336
+ <td>API extraction</td>
337
+ <td>Manual</td>
338
+ <td>Manual editing</td>
339
+ </tr>
340
+ <tr>
341
+ <td><strong>Search</strong></td>
342
+ <td>BM25 + Vector + Graph (RRF fusion)</td>
343
+ <td>Vector + Graph</td>
344
+ <td>Vector (archival)</td>
345
+ <td>Semantic</td>
346
+ <td>Vector + RAG</td>
347
+ <td>Vector-only</td>
348
+ <td>Vector + semantic</td>
349
+ <td>Decay-weighted</td>
350
+ <td>Loads everything into context</td>
351
+ </tr>
352
+ <tr>
353
+ <td><strong>Multi-agent</strong></td>
354
+ <td>MCP + REST + leases + signals</td>
355
+ <td>API (no coordination)</td>
356
+ <td>Within Letta runtime only</td>
357
+ <td>No</td>
358
+ <td>No</td>
359
+ <td>No</td>
360
+ <td>Scoped only</td>
361
+ <td>Multi-agent shared</td>
362
+ <td>Per-agent files</td>
363
+ </tr>
364
+ <tr>
365
+ <td><strong>Framework lock-in</strong></td>
366
+ <td>None (any MCP client)</td>
367
+ <td>None</td>
368
+ <td>High (must use Letta)</td>
369
+ <td>Standalone</td>
370
+ <td>None</td>
371
+ <td>None</td>
372
+ <td>Oracle Database</td>
373
+ <td>None</td>
374
+ <td>Per-agent format</td>
375
+ </tr>
376
+ <tr>
377
+ <td><strong>External deps</strong></td>
378
+ <td>None (SQLite + iii-engine)</td>
379
+ <td>Qdrant / pgvector</td>
380
+ <td>Postgres + vector DB</td>
381
+ <td>Multiple</td>
382
+ <td>Managed cloud</td>
383
+ <td>Vector store</td>
384
+ <td>Oracle AI Database</td>
385
+ <td>None</td>
386
+ <td>None</td>
387
+ </tr>
388
+ <tr>
389
+ <td><strong>Memory lifecycle</strong></td>
390
+ <td>4-tier consolidation + decay + auto-forget</td>
391
+ <td>Passive extraction</td>
392
+ <td>Agent-managed</td>
393
+ <td>Manual</td>
394
+ <td>Auto-forget</td>
395
+ <td>None</td>
396
+ <td>Not stated</td>
397
+ <td>Decay + consolidation</td>
398
+ <td>Manual pruning</td>
399
+ </tr>
400
+ <tr>
401
+ <td><strong>Token efficiency</strong></td>
402
+ <td>~1,900 tokens/session ($10/yr)</td>
403
+ <td>Varies by integration</td>
404
+ <td>Core memory in context</td>
405
+ <td>Varies</td>
406
+ <td>Cloud pricing</td>
407
+ <td>No token budget</td>
408
+ <td>LLM-backed (varies)</td>
409
+ <td>Varies</td>
410
+ <td>22K+ tokens at 240 obs</td>
411
+ </tr>
412
+ <tr>
413
+ <td><strong>Real-time viewer</strong></td>
414
+ <td>Yes (port 3113)</td>
415
+ <td>Cloud dashboard</td>
416
+ <td>Cloud dashboard</td>
417
+ <td>Web UI</td>
418
+ <td>Cloud dashboard</td>
419
+ <td>No</td>
420
+ <td>No</td>
421
+ <td>No</td>
422
+ <td>No</td>
423
+ </tr>
424
+ <tr>
425
+ <td><strong>Self-hosted</strong></td>
426
+ <td>Yes (default)</td>
427
+ <td>Optional</td>
428
+ <td>Optional</td>
429
+ <td>Yes</td>
430
+ <td>No (cloud-only)</td>
431
+ <td>Yes</td>
432
+ <td>Yes (Oracle DB)</td>
433
+ <td>Yes</td>
434
+ <td>Yes</td>
435
+ </tr>
436
+ </table>
437
+
438
+ <sub>Benchmark note: only agentmemory's R@5 is our own measured result (LongMemEval-S, reproducible from <a href="benchmark/COMPARISON.md"><code>benchmark/COMPARISON.md</code></a>). The mem0 and Letta figures are their published LoCoMo numbers (a different dataset); the MemPalace, supermemory, and oracleagentmemory figures are vendor self-reported claims we have not independently reproduced (oracleagentmemory's run used GPT-5.5 against an Oracle AI Database). Shown side by side for ballpark only, not a head-to-head on identical data. Star counts are approximate and drift over time.</sub>
439
+
440
+ ---
441
+
442
+ <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>
443
+
444
+ Compatibility: this release targets stable `iii-sdk` `^0.11.0` and iii-engine v0.11.x.
445
+
446
+ ### Try it in 30 seconds
447
+
448
+ ```bash
449
+ # Terminal 1: start the server
450
+ npx @agentmemory/agentmemory
451
+
452
+ # Terminal 2: seed sample data and see recall in action
453
+ npx @agentmemory/agentmemory demo
454
+ ```
455
+
456
+ `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.
457
+
458
+ Open `http://localhost:3113` to watch the memory build live.
459
+
460
+ ### Recommended: install globally
461
+
462
+ `npx` caches per-version. If you ran `npx @agentmemory/agentmemory@0.9.14` last week, a bare `npx @agentmemory/agentmemory` may serve the stale 0.9.14 from `~/.npm/_npx/`, not the latest release. Install once and the bare `agentmemory` command works everywhere:
463
+
464
+ ```bash
465
+ npm install -g @agentmemory/agentmemory
466
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
467
+ # sudo npm install -g @agentmemory/agentmemory
468
+ agentmemory # start the server (same as the npx form)
469
+ agentmemory stop # tear it down
470
+ agentmemory remove # uninstall everything we created
471
+ agentmemory connect claude-code # wire one agent
472
+ agentmemory doctor # interactive diagnostics + fix prompts
473
+ ```
474
+
475
+ From v0.9.16 onward, the first npx run prompts you to install globally inline — answer `Y` once and you're set. If you skip, fall back to either of these for a fresh fetch:
476
+
477
+ ```bash
478
+ npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
479
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
480
+ ```
481
+
482
+ On Windows / PowerShell, the equivalent cache clear is `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — the `npx -y ...@latest` form above is the cross-platform option.
483
+
484
+ ### Session Replay
485
+
486
+ Every session agentmemory records is replayable. Open the viewer, pick the **Replay** tab, and scrub through the timeline: prompts, tool calls, tool results, and responses render as discrete events with play/pause, speed control (0.5×–4×), and keyboard shortcuts (space to toggle, arrows to step).
487
+
488
+ Already have older Claude Code JSONL transcripts you want to bring in?
489
+
490
+ ```bash
491
+ # Import everything under the default ~/.claude/projects
492
+ npx @agentmemory/agentmemory import-jsonl
493
+
494
+ # Or import a single file
495
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
496
+ ```
497
+
498
+ Imported sessions show up in the Replay picker alongside native ones. Under the hood each entry routes through the `mem::replay::load`, `mem::replay::sessions`, and `mem::replay::import-jsonl` iii functions — no side-channel servers.
499
+
500
+ > **Heads-up if you rely on `import-jsonl` as your primary capture path:** Claude Code's `cleanupPeriodDays` (in `~/.claude/settings.json`, default **30**) auto-deletes JSONL transcripts older than that window from `~/.claude/projects/`. If you install agentmemory fresh on a months-old Claude Code history, anything older than 30 days is already gone before the first import. Either run `import-jsonl` on a cron, raise `cleanupPeriodDays` to something higher, or wire the auto-capture hooks (the default plugin install path) so each turn lands in agentmemory while the session is live and the JSONL cleanup stops mattering.
501
+
502
+ ### Upgrade / Maintenance
503
+
504
+ Use the maintenance command when you intentionally want to update your local runtime:
505
+
506
+ ```bash
507
+ npx @agentmemory/agentmemory upgrade
508
+ ```
509
+
510
+ Warning: this command mutates the current workspace/runtime. It can update JavaScript dependencies and pull the pinned `iiidev/iii:0.11.2` Docker image. It never installs an unpinned or newer iii engine.
511
+
512
+ Implementation details live in `src/cli.ts` (see `runUpgrade` around the `src/cli.ts:544-595` region).
513
+
514
+ ### Claude Code (one block, paste it)
515
+
516
+ ```text
517
+ 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` — the plugin registers all 12 hooks, 15 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
518
+ ```
519
+
520
+ #### Claude Code without the plugin install (MCP-standalone path)
521
+
522
+ If you wire agentmemory's MCP server through `~/.claude.json` directly instead of using `/plugin install`, Claude Code never resolves `${CLAUDE_PLUGIN_ROOT}` and you have to point hook scripts at absolute paths in `~/.claude/settings.json`. Those paths typically embed the agentmemory version (e.g. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.22/scripts/…`), so the next upgrade silently breaks every hook.
523
+
524
+ Workaround:
525
+
526
+ ```bash
527
+ agentmemory connect claude-code --with-hooks
528
+ ```
529
+
530
+ This merges the same hook commands into `~/.claude/settings.json` with absolute paths resolved to the bundled `plugin/` directory of the currently installed `@agentmemory/agentmemory` package. Re-run the command after upgrading agentmemory to refresh the paths. User entries in the same file are preserved; only previous agentmemory entries are replaced. Using the `/plugin install` path remains the recommended approach.
531
+ For remote or protected deployments, launch Claude Code with `AGENTMEMORY_URL` and `AGENTMEMORY_SECRET` set. The plugin passes both values through to its bundled MCP server; when `AGENTMEMORY_URL` is empty, the MCP shim uses `http://localhost:3111`.
532
+
533
+ ### Codex CLI (Codex plugin platform)
534
+
535
+ ```bash
536
+ # 1. start the memory server in a separate terminal
537
+ npx @agentmemory/agentmemory
538
+
539
+ # 2. register the agentmemory marketplace and install the plugin
540
+ codex plugin marketplace add rohitg00/agentmemory
541
+ codex plugin add agentmemory@agentmemory
542
+ ```
543
+
544
+ The Codex plugin ships from the same `plugin/` directory as the Claude Code plugin. It registers:
545
+
546
+ - `@agentmemory/mcp` as an MCP server (proxies all 53 tools when `AGENTMEMORY_URL` points at a running agentmemory server; falls back to 7 tools locally when no server is reachable)
547
+ - 6 lifecycle hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
548
+ - 8 invocable skills: `/recall`, `/remember`, `/session-history`, `/forget`, `/recap`, `/handoff`, `/commit-context`, `/commit-history`, plus 7 reference skills the agent loads on demand (MCP tools, REST API, config, agents, hooks, architecture, and the skill-authoring guide)
549
+
550
+ Codex's hook engine injects `CLAUDE_PLUGIN_ROOT` into hook subprocesses (per [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), so the same hook scripts work across both hosts without duplication. Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure events are Claude-Code-only and are not registered for Codex.
551
+
552
+ #### Codex Desktop: plugin hooks currently silent (workaround available)
553
+
554
+ `CodexHooks` and `PluginHooks` are both stable + default-enabled in [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), but Codex Desktop builds currently do not dispatch plugin-local `hooks.json` ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). MCP tools still work; only the lifecycle observations are missing.
555
+
556
+ Until upstream lands the fix, mirror the same hook commands into the global `~/.codex/hooks.json`:
557
+
558
+ ```bash
559
+ agentmemory connect codex --with-hooks
560
+ ```
561
+
562
+ This adds an idempotent block to `~/.codex/hooks.json` referencing absolute paths to the bundled scripts (no `${CLAUDE_PLUGIN_ROOT}` expansion needed at user-scope). Re-run the same command after upgrading agentmemory to refresh paths. User entries in the same file are preserved; only previous agentmemory entries are replaced.
563
+
564
+ ### GitHub Copilot CLI
565
+
566
+ ```bash
567
+ # MCP-only wiring
568
+ agentmemory connect copilot-cli
569
+
570
+ # Full hooks/skills plugin from the GitHub subdir
571
+ copilot plugin install rohitg00/agentmemory:plugin
572
+ ```
573
+
574
+ `agentmemory connect copilot-cli` merges `mcpServers.agentmemory` into `~/.copilot/mcp-config.json` (or `$COPILOT_HOME/mcp-config.json` when `COPILOT_HOME` is set) and preserves existing servers. This adapter is Windows-safe even though other `connect` adapters still require manual Windows setup. Copilot picks up the MCP server on next launch or after `/mcp`. Install the plugin as well when you want the full hook/skill experience.
575
+
576
+ <details>
577
+ <summary><b>OpenClaw (paste this prompt)</b></summary>
578
+
579
+ ```text
580
+ 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 53 memory tools:
581
+
582
+ {
583
+ "mcpServers": {
584
+ "agentmemory": {
585
+ "command": "npx",
586
+ "args": ["-y", "@agentmemory/mcp"],
587
+ "env": {
588
+ "AGENTMEMORY_URL": "http://localhost:3111"
589
+ }
590
+ }
591
+ }
592
+ }
593
+
594
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
595
+ ```
596
+
597
+ Full guide: [`integrations/openclaw/`](integrations/openclaw/)
598
+
599
+ </details>
600
+
601
+ <details>
602
+ <summary><b>Hermes Agent (paste this prompt)</b></summary>
603
+
604
+ ```text
605
+ 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 53 memory tools:
606
+
607
+ mcp_servers:
608
+ agentmemory:
609
+ command: npx
610
+ args: ["-y", "@agentmemory/mcp"]
611
+
612
+ memory:
613
+ provider: agentmemory
614
+
615
+ 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/agentmemory.
616
+ ```
617
+
618
+ Full guide: [`integrations/hermes/`](integrations/hermes/)
619
+
620
+ </details>
621
+
622
+ ### Other agents
623
+
624
+ Start the memory server: `npx @agentmemory/agentmemory`
625
+
626
+ #### Native skills via `npx skills add` (50+ agents)
627
+
628
+ agentmemory ships 15 skills in the Claude-Code-style `<dir>/SKILL.md` format: 8 invocable action skills (`remember`, `recall`, `recap`, `handoff`, `forget`, `commit-context`, `commit-history`, `session-history`) and 7 reference skills the agent loads on demand (`agentmemory-mcp-tools`, `agentmemory-rest-api`, `agentmemory-config`, `agentmemory-agents`, `agentmemory-hooks`, `agentmemory-architecture`, `write-agentmemory-skill`). The reference skills carry data tables generated from source, so they never drift. The [`skills`](https://npmjs.com/package/skills) CLI by vercel-labs auto-installs them into the calling agent's native skill directory across 50+ agents (Claude Code, Cursor, Cline, Continue, Droid, Warp, Codex, Antigravity, Kiro, OpenCode, Goose, Roo, Trae, Windsurf, and more):
629
+
630
+ ```bash
631
+ npx skills add rohitg00/agentmemory -y # auto-detects the calling agent
632
+ npx skills add rohitg00/agentmemory -y -a warp # explicit agent
633
+ npx skills add rohitg00/agentmemory -y -a '*' # install to every installed agent
634
+ ```
635
+
636
+ This is **complementary** to `agentmemory connect <agent>`:
637
+
638
+ - `agentmemory connect <agent>` writes the MCP server config so the tools are available.
639
+ - `npx skills add rohitg00/agentmemory` installs the skills so the agent knows when to call them.
640
+
641
+ For the few agents the skills CLI doesn't cover yet (Zed v1.3.x and below), drop the 15 SKILL.md files under the agent's native skill directory yourself — same format works everywhere.
642
+
643
+ #### Standard MCP block
644
+
645
+ The agentmemory entry is the **same MCP server block** across every host that uses the `mcpServers` shape (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
646
+
647
+ ```json
648
+ "agentmemory": {
649
+ "command": "npx",
650
+ "args": ["-y", "@agentmemory/mcp"],
651
+ "env": {
652
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
653
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
654
+ }
655
+ }
656
+ ```
657
+
658
+ **Merge this entry into the existing `mcpServers` object** in the host's config file — don't replace the file. If the file already has other servers, add `agentmemory` next to them as another key inside `mcpServers`. If `mcpServers` is missing entirely, paste the block inside `{ "mcpServers": { ... } }`. The `${VAR}` placeholders inherit `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` from the shell at MCP-server launch — unset vars pass empty strings and the shim falls back to `http://localhost:3111`. One wired entry covers both local and remote (k8s / reverse-proxied) deployments.
659
+
660
+ | Agent | Config file | Notes |
661
+ |---|---|---|
662
+ | **Cursor** | `~/.cursor/mcp.json` | Merge into `mcpServers`. One-click deeplink also available on the website. |
663
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | Merge into `mcpServers`. Restart Claude Desktop after editing. |
664
+ | **Cline / Roo Code / Kilo Code** | Cline MCP settings (Settings UI → MCP Servers → Edit) | Same `mcpServers` block. |
665
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Same `mcpServers` block. |
666
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (auto-merges). |
667
+ | **GitHub Copilot CLI (MCP only)** | `~/.copilot/mcp-config.json` | `agentmemory connect copilot-cli` merges `mcpServers.agentmemory`; Copilot picks it up on next launch or `/mcp`. |
668
+ | **GitHub Copilot CLI (full plugin)** | Copilot plugin install | `copilot plugin install rohitg00/agentmemory:plugin` for the plugin from the GitHub subdir. |
669
+ | **OpenClaw** | OpenClaw MCP config | Same `mcpServers` block, or use the deeper [memory plugin](integrations/openclaw/). |
670
+ | **Codex CLI (MCP only)** | `.codex/config.toml` | TOML shape: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, or add `[mcp_servers.agentmemory]` manually. |
671
+ | **Codex CLI (full plugin)** | Codex plugin marketplace | `codex plugin marketplace add rohitg00/agentmemory` then `codex plugin add agentmemory@agentmemory`. Registers MCP + 6 lifecycle hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 15 skills. On Codex Desktop, also run `agentmemory connect codex --with-hooks` until [openai/codex#16430](https://github.com/openai/codex/issues/16430) lands — plugin hooks are currently silent there. |
672
+ | **OpenCode (MCP only)** | `opencode.json` | Different shape — top-level `mcp` key, command as array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
673
+ | **OpenCode (full plugin)** | `plugin/opencode/` | 22 auto-capture hooks covering session lifecycle, messages, tools, errors. Two slash commands (`/recall`, `/remember`). Copy `plugin/opencode/` into your OpenCode workspace and add the plugin entry to `opencode.json`. See [`plugin/opencode/README.md`](plugin/opencode/README.md) for the full hook table + gap analysis. |
674
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | Copy [`integrations/pi`](integrations/pi/) and restart pi. |
675
+ | **Hermes Agent** | `~/.hermes/config.yaml` | Use the deeper [memory provider plugin](integrations/hermes/) with `memory.provider: agentmemory`. |
676
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` writes the standard `mcpServers` block. Hook payload is field-compatible with Claude Code, so the existing 12-hook scripts work without modification — wire them via the `hooks` section in the same `settings.json`. |
677
+ | **Antigravity** (replaces Gemini CLI) | `mcp_config.json` (in Antigravity's User dir) | `agentmemory connect antigravity` writes the standard `mcpServers` block. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. Use after the 2026-06-18 Gemini CLI sunset. |
678
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` writes the user-level config. Workspace overrides go in `.kiro/settings/mcp.json` next to your code. |
679
+ | **Warp** | `~/.warp/.mcp.json` | `agentmemory connect warp` writes the standard `mcpServers` block. Warp also auto-discovers skills from `.claude/skills/` — once the Claude Code plugin is installed the 8 agentmemory skills (`remember`, `recall`, `recap`, `handoff`, `forget`, `commit-context`, `commit-history`, `session-history`) appear natively in Warp's slash-command palette. |
680
+ | **Cline (CLI)** | `~/.cline/mcp.json` | `agentmemory connect cline` writes the standard `mcpServers` block. VS Code extension users: paste the same block via Cline Settings → MCP Servers → Edit JSON. |
681
+ | **Continue.dev** | `~/.continue/config.yaml` (preferred) or `config.json` (legacy) | `agentmemory connect continue` creates `config.yaml` from scratch when neither exists, or modifies existing `config.json`. **If you already have `config.yaml`** the adapter prints the exact block to paste under `mcpServers:` — it won't silently rewrite your yaml because preserving comments and anchors safely needs a YAML parser the package doesn't ship. Continue uses array form (not object) for `mcpServers`. |
682
+ | **Zed** | `~/.config/zed/settings.json` | `agentmemory connect zed` writes under `context_servers` (Zed's key, NOT `mcpServers`). Remote MCP servers can be wired via `{"url": "..."}` instead. |
683
+ | **Droid (Factory.ai)** | `~/.factory/mcp.json` | `agentmemory connect droid` writes the standard `mcpServers` block. Project-scoped overrides go in `<repo>/.factory/mcp.json`. The `/mcp` slash command inside droid lists configured servers. |
684
+ | **Goose** | Goose MCP settings UI | Same `mcpServers` block — use `goose configure` → Add Extension → MCP. Direct YAML edit at `~/.config/goose/config.yaml` is supported but the schema uses `extensions:` + `cmd` (not `mcpServers:` + `command`). |
685
+ | **Aider** | n/a | Talk to the REST API directly: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
686
+ | **Any agent (32+)** | n/a | `npx skillkit install agentmemory` auto-detects the host and merges. |
687
+
688
+ **Sandboxed MCP clients** (Flatpak / Snap / restrictive containers) that can't reach the host's `localhost`: also set `"AGENTMEMORY_FORCE_PROXY": "1"` in the `env` block, and point `AGENTMEMORY_URL` at a route the sandbox can actually reach (e.g. your LAN IP).
689
+
690
+ ### Programmatic access (Python / Rust / Node)
691
+
692
+ agentmemory registers its core operations as iii functions (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). Any language with an iii SDK can call them directly over `ws://localhost:49134` — no separate REST client per language.
693
+
694
+ ```bash
695
+ pip install iii-sdk # Python
696
+ cargo add iii-sdk # Rust
697
+ npm install iii-sdk # Node
698
+ ```
699
+
700
+ ```python
701
+ from iii import register_worker
702
+
703
+ iii = register_worker("ws://localhost:49134")
704
+ iii.connect()
705
+
706
+ iii.trigger({
707
+ "function_id": "mem::smart-search",
708
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
709
+ })
710
+ ```
711
+
712
+ Worked example: [`examples/python/`](examples/python/) (quickstart + observation/recall flow). REST on `:3111` remains available for hosts without an iii runtime.
713
+
714
+ ### From source
715
+
716
+ ```bash
717
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
718
+ npm install && npm run build && npm start
719
+ ```
720
+
721
+ 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.
722
+
723
+ Install `iii-engine` manually. **agentmemory currently pins `iii-engine` to `v0.11.2`** — `v0.11.6` introduces a new sandbox-everything-via-`iii worker add` model that agentmemory hasn't been refactored for yet. Pin lifts once the refactor lands. Override with `AGENTMEMORY_III_VERSION=<version>` if you've migrated to the sandbox model manually.
724
+
725
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
726
+ - **macOS x64:** swap `aarch64-apple-darwin` for `x86_64-apple-darwin`
727
+ - **Linux x64:** swap for `x86_64-unknown-linux-gnu`
728
+ - **Linux arm64:** swap for `aarch64-unknown-linux-gnu`
729
+ - **Windows:** download `iii-x86_64-pc-windows-msvc.zip` from [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2), extract `iii.exe`, add to PATH
730
+
731
+ Or use Docker (the bundled `docker-compose.yml` pulls `iiidev/iii:0.11.2`). Full docs: [iii.dev/docs](https://iii.dev/docs).
732
+
733
+ ### Windows
734
+
735
+ 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:
736
+
737
+ **Option A — Prebuilt Windows binary (recommended):**
738
+
739
+ ```powershell
740
+ # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
741
+ # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
742
+ # model that engine v0.11.6+ requires)
743
+ # 2. Download iii-x86_64-pc-windows-msvc.zip
744
+ # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
745
+ # 3. Extract iii.exe somewhere on PATH, or place it at:
746
+ # %USERPROFILE%\.local\bin\iii.exe
747
+ # (agentmemory checks that location automatically)
748
+ # 4. Verify:
749
+ iii --version
750
+ # Should print: 0.11.2
751
+
752
+ # 5. Then run agentmemory as usual:
753
+ npx -y @agentmemory/agentmemory
754
+ ```
755
+
756
+ **Option B — Docker Desktop:**
757
+
758
+ ```powershell
759
+ # 1. Install Docker Desktop for Windows
760
+ # 2. Start Docker Desktop and make sure the engine is running
761
+ # 3. Run agentmemory — it will auto-start the bundled compose file:
762
+ npx -y @agentmemory/agentmemory
763
+ ```
764
+
765
+ **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:
766
+
767
+ ```powershell
768
+ npx -y @agentmemory/agentmemory mcp
769
+ # or via the shim package:
770
+ npx -y @agentmemory/mcp
771
+ ```
772
+
773
+ **Diagnostics for Windows:** if `npx @agentmemory/agentmemory` fails, re-run with `--verbose` to see the actual engine stderr. Common failure modes:
774
+
775
+ | Symptom | Fix |
776
+ |---|---|
777
+ | `iii-engine process started` then `did not become ready within 15s` | Engine crashed on startup — re-run with `--verbose`, check stderr |
778
+ | `Could not start iii-engine` | Neither `iii.exe` nor Docker is installed. See Option A or B above |
779
+ | Port conflict | `netstat -ano \| findstr :3111` to see what's bound, then kill it or use `--port <N>` |
780
+ | Docker fallback skipped even though Docker is installed | Make sure Docker Desktop is actually running (system tray icon) |
781
+
782
+ > Note: the iii **engine** is a prebuilt binary, not a cargo crate — don't try to `cargo install` it. (The iii **SDKs** are published on crates.io, npm, and PyPI, but agentmemory doesn't need them.) Supported engine install methods, all pinned to v0.11.2: the prebuilt v0.11.2 binary above, the upstream sh install script **with the version pin** `curl -fsSL https://install.iii.dev/iii/main/install.sh | VERSION=0.11.2 sh` (macOS/Linux), and the Docker image `iiidev/iii:0.11.2`. A bare `install.sh | sh` installs the **latest** engine, which agentmemory does not support — always pass `VERSION=0.11.2`. Easiest of all: just run `npx @agentmemory/agentmemory`, which fetches the pinned engine into `~/.agentmemory/bin` for you.
783
+
784
+ ---
785
+
786
+ <h2 id="deploy">Deploy</h2>
787
+
788
+ One-click templates for managed hosts. Each one ships a self-contained
789
+ Dockerfile that pulls `@agentmemory/agentmemory` from npm and copies
790
+ the iii engine binary in from the official `iiidev/iii` Docker Hub
791
+ image — no pre-built agentmemory image required. Persistent storage
792
+ mounts at `/data`; the first-boot entrypoint overwrites the
793
+ npm-bundled iii config (which binds `127.0.0.1`) with a deploy-tuned
794
+ one that binds `0.0.0.0` and uses absolute `/data` paths, generates
795
+ the HMAC secret, then drops privileges from `root` to `node` via
796
+ `gosu` before exec'ing the agentmemory CLI.
797
+
798
+ <p>
799
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
800
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
801
+ </p>
802
+
803
+ Render's one-click deploy button requires `render.yaml` at the repository root, which we deliberately keep clean. Use the Render Blueprint flow documented in [`deploy/render/`](./deploy/render/README.md) to point at the in-repo blueprint manually.
804
+
805
+ Full setup details (HMAC capture, viewer SSH tunnel, rotation, backup,
806
+ cost floors) live in [`deploy/`](./deploy/README.md):
807
+
808
+ - [`deploy/fly`](./deploy/fly/README.md) — single machine with
809
+ `auto_stop_machines = "stop"`; cheapest idle.
810
+ - [`deploy/railway`](./deploy/railway/README.md) — Hobby plan flat fee,
811
+ volume in the dashboard.
812
+ - [`deploy/render`](./deploy/render/README.md) — Blueprint flow,
813
+ automatic disk snapshots on paid plans.
814
+ - [`deploy/coolify`](./deploy/coolify/README.md) — self-hosted on your
815
+ own VPS via [Coolify](https://coolify.io/self-hosted); same Docker
816
+ Compose stack, you own the host and the data.
817
+
818
+ Only port `3111` is published. The viewer on `3113` stays bound to
819
+ loopback inside the container — every template's README documents the
820
+ SSH-tunnel pattern for reaching it.
821
+
822
+ ---
823
+
824
+ <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>
825
+
826
+ 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.
827
+
828
+ ```text
829
+ Session 1: "Add auth to the API"
830
+ Agent writes code, runs tests, fixes bugs
831
+ agentmemory silently captures every tool use
832
+ Session ends -> observations compressed into structured memory
833
+
834
+ Session 2: "Now add rate limiting"
835
+ Agent already knows:
836
+ - Auth uses JWT middleware in src/middleware/auth.ts
837
+ - Tests in test/auth.test.ts cover token validation
838
+ - You chose jose over jsonwebtoken for Edge compatibility
839
+ Zero re-explaining. Starts working immediately.
840
+ ```
841
+
842
+ ### vs built-in agent memory
843
+
844
+ 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.
845
+
846
+ | | Built-in (CLAUDE.md) | agentmemory |
847
+ |---|---|---|
848
+ | Scale | 200-line cap | Unlimited |
849
+ | Search | Loads everything into context | BM25 + vector + graph (top-K only) |
850
+ | Token cost | 22K+ at 240 observations | ~1,900 tokens (92% less) |
851
+ | Cross-agent | Per-agent files | MCP + REST (any agent) |
852
+ | Coordination | None | Leases, signals, actions, routines |
853
+ | Observability | Read files manually | Real-time viewer on :3113 |
854
+
855
+ ---
856
+
857
+ <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>
858
+
859
+ ### Memory Pipeline
860
+
861
+ ```text
862
+ PostToolUse hook fires
863
+ -> SHA-256 dedup (5min window)
864
+ -> Privacy filter (strip secrets, API keys)
865
+ -> Store raw observation
866
+ -> LLM compress -> structured facts + concepts + narrative
867
+ -> Vector embedding (6 providers + local)
868
+ -> Index in BM25 + vector
869
+
870
+ Stop / SessionEnd hook fires
871
+ -> Summarize session
872
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
873
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
874
+
875
+ SessionStart hook fires
876
+ -> Load project profile (top concepts, files, patterns)
877
+ -> Hybrid search (BM25 + vector + graph)
878
+ -> Token budget (default: 2000 tokens)
879
+ -> Inject into conversation
880
+ ```
881
+
882
+ ### 4-Tier Memory Consolidation
883
+
884
+ Inspired by how human brains process memory — not unlike sleep consolidation.
885
+
886
+ | Tier | What | Analogy |
887
+ |------|------|---------|
888
+ | **Working** | Raw observations from tool use | Short-term memory |
889
+ | **Episodic** | Compressed session summaries | "What happened" |
890
+ | **Semantic** | Extracted facts and patterns | "What I know" |
891
+ | **Procedural** | Workflows and decision patterns | "How to do it" |
892
+
893
+ Memories decay over time (Ebbinghaus curve). Frequently accessed memories strengthen. Stale memories auto-evict. Contradictions are detected and resolved.
894
+
895
+ ### What Gets Captured
896
+
897
+ | Hook | Captures |
898
+ |------|----------|
899
+ | `SessionStart` | Project path, session ID |
900
+ | `UserPromptSubmit` | User prompts (privacy-filtered) |
901
+ | `PreToolUse` | File access patterns + enriched context |
902
+ | `PostToolUse` | Tool name, input, output |
903
+ | `PostToolUseFailure` | Error context |
904
+ | `PreCompact` | Re-injects memory before compaction |
905
+ | `SubagentStart/Stop` | Sub-agent lifecycle |
906
+ | `Stop` | End-of-session summary |
907
+ | `SessionEnd` | Session complete marker |
908
+
909
+ ### Key Capabilities
910
+
911
+ | Capability | Description |
912
+ |---|---|
913
+ | **Automatic capture** | Every tool use recorded via hooks — zero manual effort |
914
+ | **Semantic search** | BM25 + vector + knowledge graph with RRF fusion |
915
+ | **Memory evolution** | Versioning, supersession, relationship graphs |
916
+ | **Auto-forgetting** | TTL expiry, contradiction detection, importance eviction |
917
+ | **Privacy first** | API keys, secrets, `<private>` tags stripped before storage |
918
+ | **Self-healing** | Circuit breaker, provider fallback chain, health monitoring |
919
+ | **Claude bridge** | Bi-directional sync with MEMORY.md |
920
+ | **Knowledge graph** | Entity extraction + BFS traversal |
921
+ | **Team memory** | Namespaced shared + private across team members |
922
+ | **Citation provenance** | Trace any memory back to source observations |
923
+ | **Git snapshots** | Version, rollback, and diff memory state |
924
+
925
+ ---
926
+
927
+ <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>
928
+
929
+ Triple-stream retrieval combining three signals:
930
+
931
+ | Stream | What it does | When |
932
+ |---|---|---|
933
+ | **BM25** | Stemmed keyword matching with synonym expansion | Always on |
934
+ | **Vector** | Cosine similarity over dense embeddings | Embedding provider configured |
935
+ | **Graph** | Knowledge graph traversal via entity matching | Entities detected in query |
936
+
937
+ Fused with Reciprocal Rank Fusion (RRF, k=60) and session-diversified (max 3 results per session).
938
+
939
+ BM25 tokenizes Greek, Cyrillic, Hebrew, Arabic, and accented Latin out of the box. For Chinese / Japanese / Korean memories, install the optional segmenters (`npm install @node-rs/jieba tiny-segmenter`) to split CJK runs into word-level tokens; without them, agentmemory soft-falls to whole-run tokenization and prints a one-time hint on stderr.
940
+
941
+ ### Embedding providers
942
+
943
+ agentmemory auto-detects your provider. For best results, install local embeddings (free):
944
+
945
+ ```bash
946
+ npm install @xenova/transformers
947
+ ```
948
+
949
+ | Provider | Model | Cost | Notes |
950
+ |---|---|---|---|
951
+ | **Local (recommended)** | `all-MiniLM-L6-v2` | Free | Offline, +8pp recall over BM25-only |
952
+ | Gemini | `gemini-embedding-001` | Free tier | 100+ languages, 768/1536/3072 dims (MRL), 2048-token input. Replaces `text-embedding-004` ([deprecated, shutdown Jan 14, 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
953
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | Highest quality |
954
+ | Voyage AI | `voyage-code-3` | Paid | Optimized for code |
955
+ | Cohere | `embed-english-v3.0` | Free trial | General purpose |
956
+ | OpenRouter | Any model | Varies | Multi-model proxy |
957
+
958
+ ---
959
+
960
+ <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>
961
+
962
+ 53 tools, 6 resources, 3 prompts, and 15 skills, the most comprehensive MCP memory toolkit for any agent.
963
+
964
+ > **MCP shim vs full server:** the published `@agentmemory/mcp` package is a thin shim. It exposes the full 53-tool surface **only when it can reach a running agentmemory server** via `AGENTMEMORY_URL` (proxy mode). With no server reachable, the shim falls back to a 7-tool local set (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). The `AGENTMEMORY_TOOLS=core|all` env var is a *server-side* flag — setting it in the shim's `env` block has no effect. If you see only 7 tools in Cursor / OpenCode / Gemini CLI, start `npx @agentmemory/agentmemory` (or the Docker stack) and set `AGENTMEMORY_URL=http://localhost:3111`.
965
+
966
+ ### 53 Tools
967
+
968
+ <details>
969
+ <summary>Core tools (always available)</summary>
970
+
971
+ | Tool | Description |
972
+ |------|-------------|
973
+ | `memory_recall` | Search past observations |
974
+ | `memory_compress_file` | Compress markdown files while preserving structure |
975
+ | `memory_save` | Save an insight, decision, or pattern |
976
+ | `memory_patterns` | Detect recurring patterns |
977
+ | `memory_smart_search` | Hybrid semantic + keyword search |
978
+ | `memory_file_history` | Past observations about specific files |
979
+ | `memory_sessions` | List recent sessions |
980
+ | `memory_timeline` | Chronological observations |
981
+ | `memory_profile` | Project profile (concepts, files, patterns) |
982
+ | `memory_export` | Export all memory data |
983
+ | `memory_relations` | Query relationship graph |
984
+
985
+ </details>
986
+
987
+ <details>
988
+ <summary>Extended tools (53 total — set AGENTMEMORY_TOOLS=all)</summary>
989
+
990
+ | Tool | Description |
991
+ |------|-------------|
992
+ | `memory_patterns` | Detect recurring patterns |
993
+ | `memory_timeline` | Chronological observations |
994
+ | `memory_relations` | Query relationship graph |
995
+ | `memory_graph_query` | Knowledge graph traversal |
996
+ | `memory_consolidate` | Run 4-tier consolidation |
997
+ | `memory_claude_bridge_sync` | Sync with MEMORY.md |
998
+ | `memory_team_share` | Share with team members |
999
+ | `memory_team_feed` | Recent shared items |
1000
+ | `memory_audit` | Audit trail of operations |
1001
+ | `memory_governance_delete` | Delete with audit trail |
1002
+ | `memory_snapshot_create` | Git-versioned snapshot |
1003
+ | `memory_action_create` | Create work items with dependencies |
1004
+ | `memory_action_update` | Update action status |
1005
+ | `memory_frontier` | Unblocked actions ranked by priority |
1006
+ | `memory_next` | Single most important next action |
1007
+ | `memory_lease` | Exclusive action leases (multi-agent) |
1008
+ | `memory_routine_run` | Instantiate workflow routines |
1009
+ | `memory_signal_send` | Inter-agent messaging |
1010
+ | `memory_signal_read` | Read messages with receipts |
1011
+ | `memory_checkpoint` | External condition gates |
1012
+ | `memory_mesh_sync` | P2P sync between instances |
1013
+ | `memory_sentinel_create` | Event-driven watchers |
1014
+ | `memory_sentinel_trigger` | Fire sentinels externally |
1015
+ | `memory_sketch_create` | Ephemeral action graphs |
1016
+ | `memory_sketch_promote` | Promote to permanent |
1017
+ | `memory_crystallize` | Compact action chains |
1018
+ | `memory_diagnose` | Health checks |
1019
+ | `memory_heal` | Auto-fix stuck state |
1020
+ | `memory_facet_tag` | Dimension:value tags |
1021
+ | `memory_facet_query` | Query by facet tags |
1022
+ | `memory_verify` | Trace provenance |
1023
+
1024
+ </details>
1025
+
1026
+ ### 6 Resources · 3 Prompts · 4 Skills
1027
+
1028
+ | Type | Name | Description |
1029
+ |------|------|-------------|
1030
+ | Resource | `agentmemory://status` | Health, session count, memory count |
1031
+ | Resource | `agentmemory://project/{name}/profile` | Per-project intelligence |
1032
+ | Resource | `agentmemory://memories/latest` | Latest 10 active memories |
1033
+ | Resource | `agentmemory://graph/stats` | Knowledge graph statistics |
1034
+ | Prompt | `recall_context` | Search + return context messages |
1035
+ | Prompt | `session_handoff` | Handoff data between agents |
1036
+ | Prompt | `detect_patterns` | Analyze recurring patterns |
1037
+ | Skill | `/recall` | Search memory |
1038
+ | Skill | `/remember` | Save to long-term memory |
1039
+ | Skill | `/session-history` | Recent session summaries |
1040
+ | Skill | `/forget` | Delete observations/sessions |
1041
+
1042
+ ### Standalone MCP
1043
+
1044
+ Run without the full server — for any MCP client. Either of these works:
1045
+
1046
+ ```bash
1047
+ npx -y @agentmemory/agentmemory mcp # canonical (always available)
1048
+ npx -y @agentmemory/mcp # shim package alias
1049
+ ```
1050
+
1051
+ Or add to your agent's MCP config:
1052
+
1053
+ Most agents (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
1054
+ ```json
1055
+ {
1056
+ "mcpServers": {
1057
+ "agentmemory": {
1058
+ "command": "npx",
1059
+ "args": ["-y", "@agentmemory/mcp"],
1060
+ "env": {
1061
+ "AGENTMEMORY_URL": "http://localhost:3111"
1062
+ }
1063
+ }
1064
+ }
1065
+ }
1066
+ ```
1067
+
1068
+ Merge the `agentmemory` entry into your host's existing `mcpServers` object rather than replacing the file. For sandboxed clients that can't reach the host's `localhost`, add `"AGENTMEMORY_FORCE_PROXY": "1"` to the env block and set `AGENTMEMORY_URL` to a route the sandbox can reach.
1069
+
1070
+ OpenCode (`opencode.json`):
1071
+ ```json
1072
+ {
1073
+ "mcp": {
1074
+ "agentmemory": {
1075
+ "type": "local",
1076
+ "command": ["npx", "-y", "@agentmemory/mcp"],
1077
+ "enabled": true
1078
+ }
1079
+ },
1080
+ "plugin": ["./plugins/agentmemory-capture.ts"]
1081
+ }
1082
+ ```
1083
+
1084
+ Copy the plugin file from the repo:
1085
+ ```bash
1086
+ mkdir -p ~/.config/opencode/plugins
1087
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
1088
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
1089
+ ```
1090
+
1091
+ ---
1092
+
1093
+ <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>
1094
+
1095
+ Auto-starts on port `3113`. Live observation stream, session explorer, memory browser, knowledge graph visualization, and health dashboard.
1096
+
1097
+ ```bash
1098
+ open http://localhost:3113
1099
+ ```
1100
+
1101
+ 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'`).
1102
+
1103
+ ---
1104
+
1105
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-viewer.svg"><img src="assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
1106
+
1107
+ The viewer at `:3113` shows what your agent **remembered**. The [iii console](https://iii.dev/docs/console) shows what your agent **did** — every memory op as an OpenTelemetry trace, every KV entry editable, every function invocable, every stream tappable. Two windows on the same memory: one product-shaped, one engine-shaped.
1108
+
1109
+ Watch a `memory_smart_search` fire and see the BM25 scan → embedding lookup → RRF fusion → reranker as a waterfall. Edit a stuck consolidation timer in the KV browser. Replay a `PostToolUse` hook with a tweaked payload. Pin the WebSocket stream and watch observations land live.
1110
+
1111
+ agentmemory ships this for free because every function call and trigger fires through iii — nothing custom, nothing to instrument.
1112
+
1113
+ <p align="center">
1114
+ <img src="assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
1115
+ <br/>
1116
+ <em>Workers page: every connected worker — including agentmemory itself — with PID, function count, runtime, and last-seen.</em>
1117
+ </p>
1118
+
1119
+ **Already installed.** The console ships with `iii` — no separate installer.
1120
+
1121
+ **Launch alongside agentmemory:**
1122
+
1123
+ ```bash
1124
+ # agentmemory viewer holds port 3113, so run the console on 3114.
1125
+ # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
1126
+ iii console --port 3114
1127
+ ```
1128
+
1129
+ Then open `http://localhost:3114`. Add `--enable-flow` for the experimental architecture-graph page.
1130
+
1131
+ Override engine endpoints only if you've moved them:
1132
+
1133
+ ```bash
1134
+ iii console --port 3114 \
1135
+ --engine-port 3111 \
1136
+ --ws-port 3112 \
1137
+ --bridge-port 49134
1138
+ ```
1139
+
1140
+ **What you can do from the console:**
1141
+
1142
+ | Page | Use it to |
1143
+ |------|-----------|
1144
+ | **Workers** | See every connected worker and its live metrics — including the agentmemory worker itself. |
1145
+ | **Functions** | Invoke any of agentmemory's functions directly with a JSON payload — handy for testing `memory.recall`, `memory.consolidate`, `graph.query` without wiring a client. |
1146
+ | **Triggers** | Replay HTTP, cron, event, and state triggers — fire the consolidation cron manually, retry an HTTP route, emit a state change. |
1147
+ | **States** | KV browser with full CRUD — sessions, memory slots, lifecycle timers, embeddings index — edit values in place. |
1148
+ | **Streams** | Live WebSocket monitor for memory writes, hook events, and observation updates as they flow through iii streams. |
1149
+ | **Queues** | Durable queue topics + dead-letter management. Replay or drop failed embedding / compression jobs. |
1150
+ | **Traces** | OpenTelemetry waterfall / flame / service-breakdown views. Filter by `trace_id` to see exactly which functions, DB calls, and embedding requests a single `memory.search` produced. |
1151
+ | **Logs** | Structured OTEL logs filtered and correlated to trace/span IDs. |
1152
+ | **Config** | Runtime configuration — see exactly which workers, providers, and ports your engine is running with. |
1153
+ | **Flow** | (Optional, `--enable-flow`) Interactive architecture graph of every worker, trigger, and stream. |
1154
+
1155
+ <p align="center">
1156
+ <img src="assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1157
+ <br/>
1158
+ <em>Traces: waterfall / flame / service breakdown for every memory operation.</em>
1159
+ </p>
1160
+
1161
+ **Traces are already on:**
1162
+
1163
+ `iii-config.yaml` ships with the `iii-observability` worker enabled (`exporter: memory`, `sampling_ratio: 1.0`, metrics + logs). No extra config needed — the moment agentmemory starts, every memory operation emits a trace span and a structured log the console can read.
1164
+
1165
+ If you want to export to Jaeger/Honeycomb/Grafana Tempo instead, change `exporter: memory` to `exporter: otlp` and set the collector endpoint per iii's observability docs.
1166
+
1167
+ > **Heads-up:** no auth is enforced on the console itself — keep it bound to `127.0.0.1` (the default) and never expose it publicly.
1168
+
1169
+ ---
1170
+
1171
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-architecture.svg"><img src="assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1172
+
1173
+ agentmemory is **already a running [iii](https://iii.dev) instance**. Three primitives — worker, function, trigger — compose the runtime; KV state, streams, and OTEL traces come from iii-state, iii-stream, and iii-observability workers that ship with iii. You didn't install Postgres, Redis, Express, pm2, or Prometheus, because iii replaces them.
1174
+
1175
+ That means one more command extends agentmemory with an entire new capability.
1176
+
1177
+ ### Extend agentmemory with one command
1178
+
1179
+ ```bash
1180
+ iii worker add iii-pubsub # fan memory writes out to every connected instance
1181
+ iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1182
+ iii worker add iii-queue # durable retries for embedding + compression jobs
1183
+ iii worker add iii-observability # OTEL traces on every memory op (default on)
1184
+ iii worker add iii-sandbox # run recalled code inside an isolated microVM
1185
+ iii worker add iii-database # swap in a SQL-backed state adapter
1186
+ iii worker add mcp # generic MCP host alongside the agentmemory MCP
1187
+ ```
1188
+
1189
+ Each `iii worker add` registers new functions and triggers into the same engine agentmemory is already running on. The viewer and console pick them up immediately — no reload, no new integration, no new container.
1190
+
1191
+ | `iii worker add` | What you get on top of agentmemory |
1192
+ |---|---|
1193
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Multi-instance memory: every `remember` fans out, every `search` reads the union |
1194
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Scheduled lifecycle — nightly consolidation, weekly snapshots, decay on a fixed clock |
1195
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Durable retries: failed embedding + compression jobs survive restart, no lost observations |
1196
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | OTEL traces, metrics, logs on every function — wired in `iii-config.yaml` from day one |
1197
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | Code that came out of `memory_recall` runs inside a throwaway VM, not your shell |
1198
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | SQL-backed state adapter when you outgrow the in-memory KV defaults |
1199
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | Stand up extra MCP servers next to agentmemory's, share the same engine |
1200
+
1201
+ Full registry: [workers.iii.dev](https://workers.iii.dev). Every worker there composes through the same primitives agentmemory uses — and the agentmemory you already have is one of them.
1202
+
1203
+ ### What iii replaces
1204
+
1205
+ | Traditional stack | agentmemory uses |
1206
+ |---|---|
1207
+ | Express.js / Fastify | iii HTTP Triggers |
1208
+ | SQLite / Postgres + pgvector | iii KV State + in-memory vector index |
1209
+ | SSE / Socket.io | iii Streams (WebSocket) |
1210
+ | pm2 / systemd | iii engine worker supervision |
1211
+ | Prometheus / Grafana | iii OTEL + health monitor |
1212
+ | Custom plugin systems | `iii worker add <name>` |
1213
+
1214
+ **174 source files · ~37,800 LOC · 1,423+ tests · 258 functions · 44 KV scopes** — all on three primitives. No `agentmemory plugin install`. The plugin system is iii itself.
1215
+
1216
+ ---
1217
+
1218
+ <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>
1219
+
1220
+ ### LLM Providers
1221
+
1222
+ agentmemory auto-detects from your environment. By default, no LLM calls are made unless you configure a provider or explicitly opt in to the Claude subscription fallback.
1223
+
1224
+ | Provider | Config | Notes |
1225
+ |----------|--------|-------|
1226
+ | **No-op (default)** | No config needed | LLM-backed compress/summarize is DISABLED. Synthetic BM25 compression + recall still work. See `AGENTMEMORY_ALLOW_AGENT_SDK` below if you used to rely on the Claude-subscription fallback. |
1227
+ | Anthropic API | `ANTHROPIC_API_KEY` | Per-token billing |
1228
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic-compatible |
1229
+ | Gemini | `GEMINI_API_KEY` | Also enables embeddings |
1230
+ | OpenRouter | `OPENROUTER_API_KEY` | Any model |
1231
+ | OpenAI API | `OPENAI_API_KEY` | Default `gpt-4o-mini`, override with `OPENAI_MODEL` |
1232
+ | **Local (Ollama / LM Studio / vLLM / llama.cpp)** | `OPENAI_API_KEY=local` + `OPENAI_BASE_URL=http://localhost:11434/v1` (Ollama) or `http://localhost:1234/v1` (LM Studio) + `OPENAI_MODEL=<your model>` | Anything OpenAI-API-compatible. Zero cost, runs on your hardware. See [Local models](#local-models-ollama-lm-studio-vllm) below. |
1233
+ | Claude subscription fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Opt-in only. Spawns `@anthropic-ai/claude-agent-sdk` sessions — used to cause unbounded Stop-hook recursion so it is no longer the default. |
1234
+
1235
+ ### Local models (Ollama / LM Studio / vLLM)
1236
+
1237
+ agentmemory talks to any OpenAI-API-compatible server, so anything that exposes `/v1/chat/completions` works without code changes. No paid keys, no cloud, no rate limits — runs entirely on your hardware.
1238
+
1239
+ **Ollama** (default port `11434`):
1240
+
1241
+ ```bash
1242
+ ollama pull qwen2.5-coder:7b # or llama3.2:3b, mistral:7b, etc.
1243
+ ollama serve
1244
+ ```
1245
+
1246
+ ```env
1247
+ # ~/.agentmemory/.env
1248
+ OPENAI_API_KEY=ollama # any non-empty string; Ollama ignores it
1249
+ OPENAI_BASE_URL=http://localhost:11434/v1
1250
+ OPENAI_MODEL=qwen2.5-coder:7b
1251
+ ```
1252
+
1253
+ **LM Studio** (default port `1234`):
1254
+
1255
+ Open LM Studio → Local Server tab → Start Server. Pick any chat model from the picker (Qwen 2.5 Coder, Llama 3.2, DeepSeek, etc.).
1256
+
1257
+ ```env
1258
+ # ~/.agentmemory/.env
1259
+ OPENAI_API_KEY=lmstudio # any non-empty string; LM Studio ignores it
1260
+ OPENAI_BASE_URL=http://localhost:1234/v1
1261
+ OPENAI_MODEL=qwen2.5-coder-7b-instruct # match the model name from LM Studio
1262
+ ```
1263
+
1264
+ **vLLM / llama.cpp / Text Generation Inference**: same shape — point `OPENAI_BASE_URL` at whatever URL your server exposes, set `OPENAI_MODEL` to a name your server will accept.
1265
+
1266
+ **Model picks for memory work**: compression and summarization are short tasks (<2K tokens in, <500 tokens out) where a 7B instruct model is plenty. Recommendations:
1267
+
1268
+ | Model | Size | Why |
1269
+ |-------|------|-----|
1270
+ | `qwen2.5-coder:7b` | ~4.7 GB | Best at code-shaped sessions; trained on programming + tool-use traces |
1271
+ | `llama3.2:3b` | ~2 GB | Smallest sane option — fine for compression, weaker for graph extraction |
1272
+ | `mistral:7b-instruct` | ~4.4 GB | Good general-purpose baseline if you don't want code-specific |
1273
+ | `deepseek-r1:7b` | ~4.7 GB | Reasoning-tier quality at 7B; slower but cleaner extractions |
1274
+
1275
+ Reasoning-class models (`o1`-style with `<think>` blocks) can return empty `content` with a `reasoning` field your local server may not surface. If extractions come back blank, switch to a non-reasoning model first. The `OPENAI_REASONING_EFFORT=none` env can also disable thinking on Ollama Cloud thinking models that mirror the OpenAI reasoning schema.
1276
+
1277
+ Local embeddings ship out of the box via `@xenova/transformers` — `EMBEDDING_PROVIDER=local` (default) gives you BGE-small entirely on-device. No extra config needed.
1278
+
1279
+ ### Cost-aware model selection
1280
+
1281
+ Background compression runs on every observation, so model choice meaningfully changes monthly spend. Captured workload data: 635 requests / 888K tokens / 35 hours of active use, run against three OpenRouter models at 2026-05-23 pricing.
1282
+
1283
+ | Tier | Model | Input / 1M | Output / 1M | Cost for the captured 35h | Notes |
1284
+ |------|-------|------------|-------------|---------------------------|-------|
1285
+ | Recommended | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Solid compression + summarization quality at ~10× lower cost than Sonnet. |
1286
+ | Recommended | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Older but still fine for compression-only workloads. |
1287
+ | Recommended | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Strong code reasoning if your sessions are heavily code-shaped. |
1288
+ | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | High quality but expensive for always-on background work. |
1289
+ | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Similar tier to Sonnet. |
1290
+ | Avoid | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Reasoning-class model; massive overspend for compression. |
1291
+
1292
+ agentmemory prints a runtime warning when `OPENROUTER_MODEL` matches a premium-tier pattern. Set `AGENTMEMORY_SUPPRESS_COST_WARNING=1` to silence once you've made an informed choice.
1293
+
1294
+ Quality vs cost tradeoff for memory work: compression is a summarization task with relatively loose quality bars (the agent re-reads the summary, not the user). DeepSeek-V4-Pro / Qwen3-Coder land within rounding error of Sonnet on this task while costing ~10× less. Save the premium-tier models for queries you read directly.
1295
+
1296
+ Sources: [OpenRouter pricing for Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing notes](https://api-docs.deepseek.com/quick_start/pricing/).
1297
+
1298
+ ### Multi-agent memory (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1299
+
1300
+ In multi-agent setups where several roles share one agentmemory server (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` tags every write with the role that made it. `AGENTMEMORY_AGENT_SCOPE` controls whether recall filters by that tag.
1301
+
1302
+ ```env
1303
+ TEAM_ID=company
1304
+ USER_ID=engineering-team
1305
+ AGENT_ID=architect
1306
+ AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1307
+ ```
1308
+
1309
+ Two modes:
1310
+
1311
+ | Mode | Tag writes | Filter recall | When to use |
1312
+ |------|------------|---------------|-------------|
1313
+ | `shared` (default) | yes | no | Cross-agent context with audit trail. Architect can see what developer noted, but every row records who said it. |
1314
+ | `isolated` | yes | yes | Strict separation. Architect never sees developer's observations / memories / sessions. |
1315
+
1316
+ What gets tagged when `AGENT_ID` is set: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. The role flows from `api::session::start` → `mem::observe` → `mem::compress` → KV.
1317
+
1318
+ What gets filtered in isolated mode: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Each endpoint accepts `?agentId=<role>` to override per-request, and `?agentId=*` to opt out of the env scope entirely. `/memories` also accepts `?includeOrphans=true` to surface pre-AGENT_ID memories whose `agentId` is undefined.
1319
+
1320
+ Per-call override at the SDK / REST layer: every mutating endpoint (`/session/start`, `/remember`) accepts an `agentId` field in the request body that wins over the env. Useful for runtimes routing many roles through one server process.
1321
+
1322
+ When `AGENT_ID` is unset, memory remains unscoped (legacy behavior, no tags, no filters).
1323
+
1324
+ ### Ports
1325
+
1326
+ agentmemory + iii-engine bind four ports by default. If a restart fails with `port in use`, this table tells you which process to look for.
1327
+
1328
+ | Port | Process | Purpose | Env override |
1329
+ |------|---------|---------|--------------|
1330
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1331
+ | `3112` | iii-engine | Internal streams worker (consumed by agentmemory + viewer) | `III_STREAMS_PORT` |
1332
+ | `3113` | agentmemory | Real-time viewer (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1333
+ | `49134` | iii-engine | WebSocket — workers register here, OTel telemetry flows over it | `III_ENGINE_URL` (full URL, default `ws://localhost:49134`) |
1334
+
1335
+ Stale-process cleanup when ports stay bound after a crashed run:
1336
+
1337
+ ```bash
1338
+ # macOS / Linux — find whatever is on each port and kill it
1339
+ lsof -i :3111,3112,3113,49134
1340
+ pkill -f agentmemory || true
1341
+ pkill -f 'iii ' || true
1342
+
1343
+ # Windows
1344
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1345
+ taskkill /F /PID <pid>
1346
+ ```
1347
+
1348
+ `agentmemory stop` reaps both the worker and the engine pidfile cleanly on graceful shutdown. The manual cleanup above is only for the post-crash case where neither pidfile is left behind.
1349
+
1350
+ ### Config File
1351
+
1352
+ Put agentmemory runtime configuration in `~/.agentmemory/.env` instead of exporting variables in every shell. If the viewer shows a setup hint like `export ANTHROPIC_API_KEY=...`, copy it into this file as `ANTHROPIC_API_KEY=...` without the `export` prefix, then restart agentmemory.
1353
+
1354
+ Process environment variables still work and take precedence over values in the file.
1355
+
1356
+ On Windows, the same file lives at `%USERPROFILE%\.agentmemory\.env`:
1357
+
1358
+ ```powershell
1359
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1360
+ notepad $HOME\.agentmemory\.env
1361
+ ```
1362
+
1363
+ To test with a Claude Code Pro/Max subscription instead of an API key, opt in explicitly:
1364
+
1365
+ ```env
1366
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1367
+ AGENTMEMORY_AUTO_COMPRESS=true
1368
+ ```
1369
+
1370
+ Consolidation (graph nodes, lessons, crystals) is on by default whenever an LLM provider is configured. Explicitly opt out with `CONSOLIDATION_ENABLED=false` if you want LLM-free operation. Graph extraction is a separate flag:
1371
+
1372
+ ```env
1373
+ GRAPH_EXTRACTION_ENABLED=true
1374
+ # CONSOLIDATION_ENABLED=false # opt out of auto-consolidation
1375
+ ```
1376
+
1377
+ ### Environment Variables
1378
+
1379
+ Create `~/.agentmemory/.env`:
1380
+
1381
+ ```env
1382
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1383
+ # ANTHROPIC_API_KEY=sk-ant-...
1384
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1385
+ # GEMINI_API_KEY=...
1386
+ # OPENROUTER_API_KEY=...
1387
+ # MINIMAX_API_KEY=...
1388
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1389
+ # # OpenAI LLM provider (here) AND the OpenAI
1390
+ # # embedding provider (further below). Set
1391
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1392
+ # # to embeddings only.
1393
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1394
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1395
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1396
+ # # api-key header + api-version query param.
1397
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1398
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1399
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1400
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1401
+ # # for back-compat with v0.9.17. New configs should
1402
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1403
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1404
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1405
+ # # gpt-*-reasoning) and providers that mirror that
1406
+ # # schema (Ollama Cloud thinking models). Standard
1407
+ # # chat models reject this field with 400. Set to
1408
+ # # "none" for thinking models that return reasoning
1409
+ # # but no content.
1410
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1411
+ # # for LLM (useful if you only want OpenAI for embeddings)
1412
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1413
+ # leave OFF unless you understand the Stop-hook recursion risk:
1414
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1415
+
1416
+ # Embedding provider (auto-detected, or override)
1417
+ # EMBEDDING_PROVIDER=local
1418
+ # VOYAGE_API_KEY=...
1419
+ # OPENAI_API_KEY=sk-...
1420
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1421
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1422
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1423
+
1424
+ # Outbound LLM / embedding timeout
1425
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1426
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1427
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1428
+ # embedding). For the OpenAI LLM path, the
1429
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1430
+ # takes precedence when set, for back-compat
1431
+ # with v0.9.17.
1432
+ # Increase for slow networks or large batch calls;
1433
+ # decrease to fail-fast on rate-limit holds.
1434
+
1435
+ # Search tuning
1436
+ # BM25_WEIGHT=0.4
1437
+ # VECTOR_WEIGHT=0.6
1438
+ # TOKEN_BUDGET=2000
1439
+
1440
+ # Auth
1441
+ # AGENTMEMORY_SECRET=your-secret
1442
+
1443
+ # Ports (defaults: 3111 API, 3113 viewer)
1444
+ # III_REST_PORT=3111
1445
+
1446
+ # Features
1447
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default. When on,
1448
+ # every PostToolUse hook calls your
1449
+ # LLM provider to compress the
1450
+ # observation — expect significant
1451
+ # token spend on active sessions.
1452
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1453
+ # memory slots — persona,
1454
+ # user_preferences, tool_guidelines,
1455
+ # project_context, guidance,
1456
+ # pending_items, session_patterns,
1457
+ # self_notes. Size-limited; agent
1458
+ # edits via memory_slot_* tools.
1459
+ # Pinned slots addressable for
1460
+ # SessionStart injection.
1461
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1462
+ # Stop hook fires mem::slot-reflect:
1463
+ # scans recent observations, auto-
1464
+ # appends TODOs to pending_items,
1465
+ # counts patterns in
1466
+ # session_patterns, records touched
1467
+ # files in project_context. Fire-
1468
+ # and-forget; does not block.
1469
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default. When on:
1470
+ # - SessionStart may inject ~1-2K
1471
+ # chars of project context into
1472
+ # the first turn of each session
1473
+ # (this is what actually reaches
1474
+ # the model — Claude Code treats
1475
+ # SessionStart stdout as context)
1476
+ # - PreToolUse fires /agentmemory/enrich
1477
+ # on every file-touching tool call
1478
+ # (resource cleanup, not a token
1479
+ # fix — PreToolUse stdout is debug
1480
+ # log only per Claude Code docs)
1481
+ # Observations are still captured via
1482
+ # PostToolUse regardless of this flag.
1483
+ # GRAPH_EXTRACTION_ENABLED=false
1484
+ # CONSOLIDATION_ENABLED=false # on by default when an LLM provider is configured
1485
+ # LESSON_DECAY_ENABLED=true
1486
+ # OBSIDIAN_AUTO_EXPORT=false
1487
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1488
+ # CLAUDE_MEMORY_BRIDGE=false
1489
+ # SNAPSHOT_ENABLED=false
1490
+
1491
+ # Team
1492
+ # TEAM_ID=
1493
+ # USER_ID=
1494
+ # TEAM_MODE=private
1495
+
1496
+ # Tool visibility: "core" (8 tools, lean fallback) or "all" (53 tools)
1497
+ # AGENTMEMORY_TOOLS=core
1498
+ ```
1499
+
1500
+ ---
1501
+
1502
+ <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>
1503
+
1504
+ 128 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.
1505
+
1506
+ <details>
1507
+ <summary>Key endpoints</summary>
1508
+
1509
+ | Method | Path | Description |
1510
+ |--------|------|-------------|
1511
+ | `GET` | `/agentmemory/health` | Health check (always public) |
1512
+ | `POST` | `/agentmemory/session/start` | Start session + get context |
1513
+ | `POST` | `/agentmemory/session/end` | End session |
1514
+ | `POST` | `/agentmemory/observe` | Capture observation |
1515
+ | `POST` | `/agentmemory/smart-search` | Hybrid search |
1516
+ | `POST` | `/agentmemory/context` | Generate context |
1517
+ | `POST` | `/agentmemory/remember` | Save to long-term memory |
1518
+ | `POST` | `/agentmemory/forget` | Delete observations |
1519
+ | `POST` | `/agentmemory/enrich` | File context + memories + bugs |
1520
+ | `GET` | `/agentmemory/profile` | Project profile |
1521
+ | `GET` | `/agentmemory/export` | Export all data |
1522
+ | `POST` | `/agentmemory/import` | Import from JSON |
1523
+ | `POST` | `/agentmemory/graph/query` | Knowledge graph query |
1524
+ | `POST` | `/agentmemory/team/share` | Share with team |
1525
+ | `GET` | `/agentmemory/audit` | Audit trail |
1526
+
1527
+ Full endpoint list: [`src/triggers/api.ts`](src/triggers/api.ts)
1528
+
1529
+ </details>
1530
+
1531
+ ---
1532
+
1533
+ <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>
1534
+
1535
+ ```bash
1536
+ npm run dev # Hot reload
1537
+ npm run build # Production build
1538
+ npm test # 1,423+ tests
1539
+ npm run test:integration # API tests (requires running services)
1540
+ ```
1541
+
1542
+ **Prerequisites:** Node.js >= 20, [iii-engine](https://iii.dev/docs) or Docker
1543
+
1544
+ <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>
1545
+
1546
+ [Apache-2.0](LICENSE)