@agentmemory/agentmemory 0.9.21 → 0.9.23

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 (95) hide show
  1. package/AGENTS.md +7 -2
  2. package/README.md +288 -33
  3. package/dist/cli.d.mts +5 -1
  4. package/dist/cli.d.mts.map +1 -0
  5. package/dist/cli.mjs +128 -703
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/connect-Cf9bmBqO.mjs +1020 -0
  8. package/dist/connect-Cf9bmBqO.mjs.map +1 -0
  9. package/dist/hooks/notification.mjs +46 -21
  10. package/dist/hooks/notification.mjs.map +1 -1
  11. package/dist/hooks/post-tool-failure.mjs +47 -21
  12. package/dist/hooks/post-tool-failure.mjs.map +1 -1
  13. package/dist/hooks/post-tool-use.mjs +57 -22
  14. package/dist/hooks/post-tool-use.mjs.map +1 -1
  15. package/dist/hooks/pre-compact.mjs +26 -2
  16. package/dist/hooks/pre-compact.mjs.map +1 -1
  17. package/dist/hooks/pre-tool-use.mjs +19 -12
  18. package/dist/hooks/pre-tool-use.mjs.map +1 -1
  19. package/dist/hooks/prompt-submit.mjs +39 -16
  20. package/dist/hooks/prompt-submit.mjs.map +1 -1
  21. package/dist/hooks/session-end.mjs +26 -33
  22. package/dist/hooks/session-end.mjs.map +1 -1
  23. package/dist/hooks/session-start.mjs +28 -3
  24. package/dist/hooks/session-start.mjs.map +1 -1
  25. package/dist/hooks/stop.mjs +14 -9
  26. package/dist/hooks/stop.mjs.map +1 -1
  27. package/dist/hooks/subagent-start.mjs +31 -4
  28. package/dist/hooks/subagent-start.mjs.map +1 -1
  29. package/dist/hooks/subagent-stop.mjs +45 -20
  30. package/dist/hooks/subagent-stop.mjs.map +1 -1
  31. package/dist/hooks/task-completed.mjs +44 -21
  32. package/dist/hooks/task-completed.mjs.map +1 -1
  33. package/dist/iii-config.docker.yaml +3 -2
  34. package/dist/iii-config.yaml +11 -2
  35. package/dist/{image-refs-R3tin9MR.mjs → image-refs-CJS5B9Gq.mjs} +2 -2
  36. package/dist/{image-refs-R3tin9MR.mjs.map → image-refs-CJS5B9Gq.mjs.map} +1 -1
  37. package/dist/{image-store-DyrKZKqZ.mjs → image-store-CdE0amb1.mjs} +1 -1
  38. package/dist/index.mjs +866 -380
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/logger-xlVlvCWX.mjs +43 -0
  41. package/dist/logger-xlVlvCWX.mjs.map +1 -0
  42. package/dist/schema-BkALl7Z_.mjs +74 -0
  43. package/dist/schema-BkALl7Z_.mjs.map +1 -0
  44. package/dist/{src-D5arboxc.mjs → src-DvS3bhMe.mjs} +844 -395
  45. package/dist/src-DvS3bhMe.mjs.map +1 -0
  46. package/dist/{standalone-C7BgzzIN.mjs → standalone-DHQcPX_g.mjs} +107 -14
  47. package/dist/standalone-DHQcPX_g.mjs.map +1 -0
  48. package/dist/standalone.d.mts.map +1 -1
  49. package/dist/standalone.mjs +108 -12
  50. package/dist/standalone.mjs.map +1 -1
  51. package/dist/{tools-registry-CRTWUFw9.mjs → tools-registry-DJizX9Az.mjs} +51 -12
  52. package/dist/tools-registry-DJizX9Az.mjs.map +1 -0
  53. package/dist/version-BPfyI4Kc.mjs +6 -0
  54. package/dist/version-BPfyI4Kc.mjs.map +1 -0
  55. package/dist/viewer/index.html +85 -10
  56. package/iii-config.docker.yaml +3 -2
  57. package/iii-config.yaml +11 -2
  58. package/package.json +6 -4
  59. package/plugin/.claude-plugin/plugin.json +2 -2
  60. package/plugin/.codex-plugin/plugin.json +2 -2
  61. package/plugin/.mcp.copilot.json +15 -0
  62. package/plugin/.mcp.json +3 -2
  63. package/plugin/hooks/hooks.copilot.json +72 -0
  64. package/plugin/opencode/agentmemory-capture.ts +34 -9
  65. package/plugin/plugin.json +15 -0
  66. package/plugin/scripts/diagnostics.d.mts +17 -0
  67. package/plugin/scripts/diagnostics.d.mts.map +1 -0
  68. package/plugin/scripts/diagnostics.mjs.map +1 -0
  69. package/plugin/scripts/notification.mjs +46 -21
  70. package/plugin/scripts/notification.mjs.map +1 -1
  71. package/plugin/scripts/post-tool-failure.mjs +47 -21
  72. package/plugin/scripts/post-tool-failure.mjs.map +1 -1
  73. package/plugin/scripts/post-tool-use.mjs +57 -22
  74. package/plugin/scripts/post-tool-use.mjs.map +1 -1
  75. package/plugin/scripts/pre-compact.mjs +26 -2
  76. package/plugin/scripts/pre-compact.mjs.map +1 -1
  77. package/plugin/scripts/pre-tool-use.mjs +19 -12
  78. package/plugin/scripts/pre-tool-use.mjs.map +1 -1
  79. package/plugin/scripts/prompt-submit.mjs +39 -16
  80. package/plugin/scripts/prompt-submit.mjs.map +1 -1
  81. package/plugin/scripts/session-end.mjs +26 -33
  82. package/plugin/scripts/session-end.mjs.map +1 -1
  83. package/plugin/scripts/session-start.mjs +28 -3
  84. package/plugin/scripts/session-start.mjs.map +1 -1
  85. package/plugin/scripts/stop.mjs +14 -9
  86. package/plugin/scripts/stop.mjs.map +1 -1
  87. package/plugin/scripts/subagent-start.mjs +31 -4
  88. package/plugin/scripts/subagent-start.mjs.map +1 -1
  89. package/plugin/scripts/subagent-stop.mjs +45 -20
  90. package/plugin/scripts/subagent-stop.mjs.map +1 -1
  91. package/plugin/scripts/task-completed.mjs +44 -21
  92. package/plugin/scripts/task-completed.mjs.map +1 -1
  93. package/dist/src-D5arboxc.mjs.map +0 -1
  94. package/dist/standalone-C7BgzzIN.mjs.map +0 -1
  95. package/dist/tools-registry-CRTWUFw9.mjs.map +0 -1
package/AGENTS.md CHANGED
@@ -19,6 +19,7 @@ agentmemory is a persistent memory system for AI coding agents, built on iii-eng
19
19
  5. `test/mcp-standalone.test.ts` — tool count assertion
20
20
  6. `README.md` — tool counts (search for "MCP tools")
21
21
  7. `plugin/.claude-plugin/plugin.json` — tool count in description
22
+ 8. `plugin/plugin.json` and `plugin/.mcp.copilot.json` (when present) — tool count or MCP exposure
22
23
 
23
24
  **When adding REST endpoints, you MUST update:**
24
25
  1. `src/triggers/api.ts` — endpoint registration
@@ -32,6 +33,7 @@ agentmemory is a persistent memory system for AI coding agents, built on iii-eng
32
33
  4. `src/functions/export-import.ts` — supportedVersions set
33
34
  5. `test/export-import.test.ts` — version assertion
34
35
  6. `plugin/.claude-plugin/plugin.json` — version field
36
+ 7. `plugin/plugin.json` (when present) — version field
35
37
 
36
38
  **When adding new KV scopes:**
37
39
  1. `src/state/schema.ts` — add to the KV object
@@ -89,7 +91,10 @@ case "memory_your_tool": {
89
91
  ```
90
92
 
91
93
  ### Hook Scripts
92
- Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import). They read JSON from stdin, make HTTP calls to the REST API, and exit. Always use `try/catch` with `AbortSignal.timeout()` for best-effort calls.
94
+ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import). They read JSON from stdin, make HTTP calls to the REST API, and exit. There are two patterns depending on whether Claude Code consumes the script's stdout:
95
+
96
+ - **Context-injecting hooks** (`pre-tool-use`, `pre-compact`, `session-start`) write recalled context to stdout for Claude Code to inject. These MUST use `try/catch` with `await fetch(..., { signal: AbortSignal.timeout(N) })` — the script has to wait for the response before exiting, and the timeout is the only bound on hang time.
97
+ - **Telemetry-only hooks** (`notification`, `post-tool-failure`, `post-tool-use`, `prompt-submit`, `stop`, `session-end`, `subagent-start`, `subagent-stop`, `task-completed`) write nothing to stdout. These MUST use fire-and-forget `fetch(..., { signal: AbortSignal.timeout(N) }).catch(() => {})` paired with `setTimeout(() => process.exit(0), 500).unref()`. The unawaited fetch dispatches the request; the unref'd `setTimeout` force-exits the process after the request has been flushed to the local daemon's socket buffer (~500ms is enough for single-request hooks; use 1500ms for multi-request hooks like `stop` and `session-end` so all fetches have time to start, especially when `AGENTMEMORY_URL` points to a remote daemon). Without the `setTimeout` Node keeps the event loop alive waiting for any in-flight fetch to settle, which means the hook still blocks Claude Code's next-prompt boundary for up to the AbortSignal duration — exactly the bug fire-and-forget is meant to fix.
93
98
 
94
99
  ## Coding Standards
95
100
 
@@ -112,7 +117,7 @@ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import).
112
117
  ## Current Stats (v0.9.16)
113
118
 
114
119
  - 53 MCP tools (8 visible by default, `AGENTMEMORY_TOOLS=all` for all)
115
- - 124 REST endpoints
120
+ - 125 REST endpoints
116
121
  - 6 MCP resources, 3 MCP prompts
117
122
  - 12 hooks, 4 skills
118
123
  - 50+ iii functions
package/README.md CHANGED
@@ -7,7 +7,22 @@
7
7
  Your coding agent remembers everything. No more re-explaining.
8
8
  Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
9
  </strong><br/>
10
- Persistent memory for Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode, and any MCP client.
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>
11
26
  </p>
12
27
 
13
28
  <p align="center">
@@ -25,7 +40,7 @@
25
40
  </p>
26
41
 
27
42
  <p align="center">
28
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
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>
29
44
  </p>
30
45
 
31
46
  <p align="center">
@@ -73,10 +88,13 @@
73
88
  ## Install
74
89
 
75
90
  ```bash
76
- npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
77
- agentmemory # start the memory server on :3111
78
- agentmemory demo # seed sample sessions + prove recall
79
- agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
91
+ npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # start the memory server on :3111
95
+ agentmemory demo # seed sample sessions + prove recall
96
+ agentmemory connect claude-code # wire MCP into your agent (also: copilot-cli, codex, cursor, gemini-cli, ...)
97
+ npx skills add rohitg00/agentmemory -y # install 8 native skills so your agent knows when to use the tools
80
98
  ```
81
99
 
82
100
  Or via `npx` (no install):
@@ -98,7 +116,7 @@ agentmemory works with any agent that supports hooks, MCP, or REST API. All agen
98
116
  <table>
99
117
  <tr>
100
118
  <td align="center" width="12.5%">
101
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <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/>
102
120
  <strong>Claude Code</strong><br/>
103
121
  <sub>native plugin + 12 hooks + MCP</sub>
104
122
  </td>
@@ -108,6 +126,11 @@ agentmemory works with any agent that supports hooks, MCP, or REST API. All agen
108
126
  <sub>native plugin + 6 hooks + MCP</sub>
109
127
  </td>
110
128
  <td align="center" width="12.5%">
129
+ <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/>
130
+ <strong>GitHub Copilot CLI</strong><br/>
131
+ <sub>MCP + plugin hooks/skills</sub>
132
+ </td>
133
+ <td align="center" width="12.5%">
111
134
  <a href="integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
112
135
  <strong>OpenClaw</strong><br/>
113
136
  <sub>native plugin + MCP</sub>
@@ -128,7 +151,7 @@ agentmemory works with any agent that supports hooks, MCP, or REST API. All agen
128
151
  <sub>native Memory trait backend</sub>
129
152
  </td>
130
153
  <td align="center" width="12.5%">
131
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
154
+ <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/>
132
155
  <strong>Cursor</strong><br/>
133
156
  <sub>MCP server</sub>
134
157
  </td>
@@ -140,7 +163,7 @@ agentmemory works with any agent that supports hooks, MCP, or REST API. All agen
140
163
  </tr>
141
164
  <tr>
142
165
  <td align="center" width="12.5%">
143
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
166
+ <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/>
144
167
  <strong>OpenCode</strong><br/>
145
168
  <sub>22 hooks + MCP + plugin</sub>
146
169
  </td>
@@ -170,7 +193,7 @@ agentmemory works with any agent that supports hooks, MCP, or REST API. All agen
170
193
  <sub>MCP server</sub>
171
194
  </td>
172
195
  <td align="center" width="12.5%">
173
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
196
+ <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/>
174
197
  <strong>Windsurf</strong><br/>
175
198
  <sub>MCP server</sub>
176
199
  </td>
@@ -180,6 +203,13 @@ agentmemory works with any agent that supports hooks, MCP, or REST API. All agen
180
203
  <sub>MCP server</sub>
181
204
  </td>
182
205
  </tr>
206
+ <tr>
207
+ <td align="center" width="12.5%">
208
+ <a href="https://www.warp.dev"><img src="https://github.com/warpdotdev.png?size=120" alt="Warp" width="48" height="48" /></a><br/>
209
+ <strong>Warp</strong><br/>
210
+ <sub>connect + MCP + skills</sub>
211
+ </td>
212
+ </tr>
183
213
  </table>
184
214
 
185
215
  <p align="center">
@@ -196,7 +226,7 @@ You explain the same architecture every session. You re-discover the same bugs.
196
226
  npx @agentmemory/agentmemory
197
227
  ```
198
228
 
199
- > **New in v0.9.0** — Landing site at [agent-memory.dev](https://agent-memory.dev), filesystem connector (`@agentmemory/fs-watcher`), standalone MCP now proxies to the running server so hooks and the viewer agree, audit policy codified across every delete path, health stops flagging `memory_critical` on tiny Node processes. Full notes in [CHANGELOG.md](CHANGELOG.md#090--2026-04-18).
229
+ > **New in v0.9.22** — Three new connect adapters (Qwen Code, Antigravity, Kiro), `AGENT_ID` multi-agent isolation with opt-in `AGENTMEMORY_AGENT_SCOPE=isolated` filtering, install ERESOLVE fixed, OpenAI thinking-model output handled, OpenCode auto-context + session creation, viewer graph settles on 1000+ nodes, 22 fixes total. Full notes in [CHANGELOG.md](CHANGELOG.md).
200
230
 
201
231
  ---
202
232
 
@@ -208,6 +238,15 @@ npx @agentmemory/agentmemory
208
238
 
209
239
  ### Retrieval Accuracy
210
240
 
241
+ **coding-agent-life-v1** (in-house corpus, sandbox-reproducible)
242
+
243
+ | Adapter | P@5 | R@5 | Top-5 hit rate | p50 latency |
244
+ |---|---|---|---|---|
245
+ | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
246
+ | grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
247
+
248
+ 100% top-5 hit rate. **2.2×** better precision than the grep baseline on identical input. Full per-type breakdown: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
249
+
211
250
  **LongMemEval-S** (ICLR 2025, 500 questions)
212
251
 
213
252
  | System | R@5 | R@10 | MRR |
@@ -233,6 +272,10 @@ npx @agentmemory/agentmemory
233
272
 
234
273
  > Embedding model: `all-MiniLM-L6-v2` (local, free, no API key). Full reports: [`benchmark/LONGMEMEVAL.md`](benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](benchmark/QUALITY.md), [`benchmark/SCALE.md`](benchmark/SCALE.md). Competitor comparison: [`benchmark/COMPARISON.md`](benchmark/COMPARISON.md) — agentmemory vs mem0, Letta, Khoj, claude-mem, Hippo.
235
274
 
275
+ **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/).
276
+
277
+ **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).
278
+
236
279
  ---
237
280
 
238
281
  <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>
@@ -350,6 +393,8 @@ Open `http://localhost:3113` to watch the memory build live.
350
393
 
351
394
  ```bash
352
395
  npm install -g @agentmemory/agentmemory
396
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
397
+ # sudo npm install -g @agentmemory/agentmemory
353
398
  agentmemory # start the server (same as the npx form)
354
399
  agentmemory stop # tear it down
355
400
  agentmemory remove # uninstall everything we created
@@ -396,10 +441,23 @@ Implementation details live in `src/cli.ts` (see `runUpgrade` around the `src/cl
396
441
 
397
442
  ### Claude Code (one block, paste it)
398
443
 
444
+ ```text
445
+ 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, 8 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.
399
446
  ```
400
- 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, 4 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.
447
+
448
+ #### Claude Code without the plugin install (MCP-standalone path)
449
+
450
+ 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 ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
451
+
452
+ Workaround:
453
+
454
+ ```bash
455
+ agentmemory connect claude-code --with-hooks
401
456
  ```
402
457
 
458
+ 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.
459
+ 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`.
460
+
403
461
  ### Codex CLI (Codex plugin platform)
404
462
 
405
463
  ```bash
@@ -408,22 +466,46 @@ npx @agentmemory/agentmemory
408
466
 
409
467
  # 2. register the agentmemory marketplace and install the plugin
410
468
  codex plugin marketplace add rohitg00/agentmemory
411
- codex plugin install agentmemory
469
+ codex plugin add agentmemory@agentmemory
412
470
  ```
413
471
 
414
472
  The Codex plugin ships from the same `plugin/` directory as the Claude Code plugin. It registers:
415
473
 
416
- - `@agentmemory/mcp` as an MCP server (proxies all 51 tools when `AGENTMEMORY_URL` points at a running agentmemory server; falls back to 7 tools locally when no server is reachable)
474
+ - `@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)
417
475
  - 6 lifecycle hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
418
- - 4 skills: `/recall`, `/remember`, `/session-history`, `/forget`
476
+ - 8 skills: `/recall`, `/remember`, `/session-history`, `/forget`, `/recap`, `/handoff`, `/commit-context`, `/commit-history`
419
477
 
420
478
  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.
421
479
 
480
+ #### Codex Desktop: plugin hooks currently silent (workaround available)
481
+
482
+ `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.
483
+
484
+ Until upstream lands the fix, mirror the same hook commands into the global `~/.codex/hooks.json`:
485
+
486
+ ```bash
487
+ agentmemory connect codex --with-hooks
488
+ ```
489
+
490
+ 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.
491
+
492
+ ### GitHub Copilot CLI
493
+
494
+ ```bash
495
+ # MCP-only wiring
496
+ agentmemory connect copilot-cli
497
+
498
+ # Full hooks/skills plugin from the GitHub subdir
499
+ copilot plugin install rohitg00/agentmemory:plugin
500
+ ```
501
+
502
+ `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.
503
+
422
504
  <details>
423
505
  <summary><b>OpenClaw (paste this prompt)</b></summary>
424
506
 
425
- ```
426
- 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 51 memory tools:
507
+ ```text
508
+ 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:
427
509
 
428
510
  {
429
511
  "mcpServers": {
@@ -447,8 +529,8 @@ Full guide: [`integrations/openclaw/`](integrations/openclaw/)
447
529
  <details>
448
530
  <summary><b>Hermes Agent (paste this prompt)</b></summary>
449
531
 
450
- ```
451
- 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 51 memory tools:
532
+ ```text
533
+ 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:
452
534
 
453
535
  mcp_servers:
454
536
  agentmemory:
@@ -469,6 +551,25 @@ Full guide: [`integrations/hermes/`](integrations/hermes/)
469
551
 
470
552
  Start the memory server: `npx @agentmemory/agentmemory`
471
553
 
554
+ #### Native skills via `npx skills add` (50+ agents)
555
+
556
+ agentmemory ships 8 skills (`remember`, `recall`, `recap`, `handoff`, `forget`, `commit-context`, `commit-history`, `session-history`) in the Claude-Code-style `<dir>/SKILL.md` format. 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):
557
+
558
+ ```bash
559
+ npx skills add rohitg00/agentmemory -y # auto-detects the calling agent
560
+ npx skills add rohitg00/agentmemory -y -a warp # explicit agent
561
+ npx skills add rohitg00/agentmemory -y -a '*' # install to every installed agent
562
+ ```
563
+
564
+ This is **complementary** to `agentmemory connect <agent>`:
565
+
566
+ - `agentmemory connect <agent>` writes the MCP server config so the tools are available.
567
+ - `npx skills add rohitg00/agentmemory` installs the skills so the agent knows when to call them.
568
+
569
+ For the few agents the skills CLI doesn't cover yet (Zed v1.3.x and below), drop the 8 SKILL.md files under the agent's native skill directory yourself — same format works everywhere.
570
+
571
+ #### Standard MCP block
572
+
472
573
  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):
473
574
 
474
575
  ```json
@@ -491,14 +592,24 @@ The agentmemory entry is the **same MCP server block** across every host that us
491
592
  | **Cline / Roo Code / Kilo Code** | Cline MCP settings (Settings UI → MCP Servers → Edit) | Same `mcpServers` block. |
492
593
  | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Same `mcpServers` block. |
493
594
  | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (auto-merges). |
595
+ | **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`. |
596
+ | **GitHub Copilot CLI (full plugin)** | Copilot plugin install | `copilot plugin install rohitg00/agentmemory:plugin` for the plugin from the GitHub subdir. |
494
597
  | **OpenClaw** | OpenClaw MCP config | Same `mcpServers` block, or use the deeper [memory plugin](integrations/openclaw/). |
495
598
  | **Codex CLI (MCP only)** | `.codex/config.toml` | TOML shape: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, or add `[mcp_servers.agentmemory]` manually. |
496
- | **Codex CLI (full plugin)** | Codex plugin marketplace | `codex plugin marketplace add rohitg00/agentmemory` then `codex plugin install agentmemory`. Registers MCP + 6 lifecycle hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills. |
599
+ | **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) + 8 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. |
497
600
  | **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}}}`. |
498
601
  | **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. |
499
602
  | **pi** | `~/.pi/agent/extensions/agentmemory` | Copy [`integrations/pi`](integrations/pi/) and restart pi. |
500
603
  | **Hermes Agent** | `~/.hermes/config.yaml` | Use the deeper [memory provider plugin](integrations/hermes/) with `memory.provider: agentmemory`. |
501
- | **Goose** | Goose MCP settings UI | Same `mcpServers` block. |
604
+ | **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`. |
605
+ | **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. |
606
+ | **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. |
607
+ | **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. |
608
+ | **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. |
609
+ | **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`. |
610
+ | **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. |
611
+ | **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. |
612
+ | **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`). |
502
613
  | **Aider** | n/a | Talk to the REST API directly: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
503
614
  | **Any agent (32+)** | n/a | `npx skillkit install agentmemory` auto-detects the host and merges. |
504
615
 
@@ -642,7 +753,7 @@ SSH-tunnel pattern for reaching it.
642
753
 
643
754
  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.
644
755
 
645
- ```
756
+ ```text
646
757
  Session 1: "Add auth to the API"
647
758
  Agent writes code, runs tests, fixes bugs
648
759
  agentmemory silently captures every tool use
@@ -675,7 +786,7 @@ Every AI coding agent ships with built-in memory — Claude Code has `MEMORY.md`
675
786
 
676
787
  ### Memory Pipeline
677
788
 
678
- ```
789
+ ```text
679
790
  PostToolUse hook fires
680
791
  -> SHA-256 dedup (5min window)
681
792
  -> Privacy filter (strip secrets, API keys)
@@ -776,11 +887,11 @@ npm install @xenova/transformers
776
887
 
777
888
  <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>
778
889
 
779
- 53 tools, 6 resources, 3 prompts, and 4 skills — the most comprehensive MCP memory toolkit for any agent.
890
+ 53 tools, 6 resources, 3 prompts, and 8 skills — the most comprehensive MCP memory toolkit for any agent.
780
891
 
781
- > **MCP shim vs full server:** the published `@agentmemory/mcp` package is a thin shim. It exposes the full 51-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`.
892
+ > **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`.
782
893
 
783
- ### 51 Tools
894
+ ### 53 Tools
784
895
 
785
896
  <details>
786
897
  <summary>Core tools (always available)</summary>
@@ -802,7 +913,7 @@ npm install @xenova/transformers
802
913
  </details>
803
914
 
804
915
  <details>
805
- <summary>Extended tools (51 total — set AGENTMEMORY_TOOLS=all)</summary>
916
+ <summary>Extended tools (53 total — set AGENTMEMORY_TOOLS=all)</summary>
806
917
 
807
918
  | Tool | Description |
808
919
  |------|-------------|
@@ -925,7 +1036,7 @@ The viewer at `:3113` shows what your agent **remembered**. The [iii console](ht
925
1036
 
926
1037
  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.
927
1038
 
928
- agentmemory ships this for free because every function, trigger, state scope, and stream is an iii primitive — nothing custom, nothing to instrument.
1039
+ agentmemory ships this for free because every function call and trigger fires through iii — nothing custom, nothing to instrument.
929
1040
 
930
1041
  <p align="center">
931
1042
  <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" />
@@ -987,7 +1098,7 @@ If you want to export to Jaeger/Honeycomb/Grafana Tempo instead, change `exporte
987
1098
 
988
1099
  <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>
989
1100
 
990
- agentmemory is **already a running [iii](https://iii.dev) instance**. Functions, triggers, KV state, streams, OTEL traces all of it is iii primitives. You didn't install Postgres, Redis, Express, pm2, or Prometheus, because iii replaces them.
1101
+ 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.
991
1102
 
992
1103
  That means one more command extends agentmemory with an entire new capability.
993
1104
 
@@ -1036,7 +1147,7 @@ Full registry: [workers.iii.dev](https://workers.iii.dev). Every worker there co
1036
1147
 
1037
1148
  ### LLM Providers
1038
1149
 
1039
- agentmemory auto-detects from your environment. No API key needed if you have a Claude subscription.
1150
+ 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.
1040
1151
 
1041
1152
  | Provider | Config | Notes |
1042
1153
  |----------|--------|-------|
@@ -1045,8 +1156,152 @@ agentmemory auto-detects from your environment. No API key needed if you have a
1045
1156
  | MiniMax | `MINIMAX_API_KEY` | Anthropic-compatible |
1046
1157
  | Gemini | `GEMINI_API_KEY` | Also enables embeddings |
1047
1158
  | OpenRouter | `OPENROUTER_API_KEY` | Any model |
1159
+ | OpenAI API | `OPENAI_API_KEY` | Default `gpt-4o-mini`, override with `OPENAI_MODEL` |
1160
+ | **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. |
1048
1161
  | 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 (#149 follow-up) so it is no longer the default. |
1049
1162
 
1163
+ ### Local models (Ollama / LM Studio / vLLM)
1164
+
1165
+ 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.
1166
+
1167
+ **Ollama** (default port `11434`):
1168
+
1169
+ ```bash
1170
+ ollama pull qwen2.5-coder:7b # or llama3.2:3b, mistral:7b, etc.
1171
+ ollama serve
1172
+ ```
1173
+
1174
+ ```env
1175
+ # ~/.agentmemory/.env
1176
+ OPENAI_API_KEY=ollama # any non-empty string; Ollama ignores it
1177
+ OPENAI_BASE_URL=http://localhost:11434/v1
1178
+ OPENAI_MODEL=qwen2.5-coder:7b
1179
+ ```
1180
+
1181
+ **LM Studio** (default port `1234`):
1182
+
1183
+ Open LM Studio → Local Server tab → Start Server. Pick any chat model from the picker (Qwen 2.5 Coder, Llama 3.2, DeepSeek, etc.).
1184
+
1185
+ ```env
1186
+ # ~/.agentmemory/.env
1187
+ OPENAI_API_KEY=lmstudio # any non-empty string; LM Studio ignores it
1188
+ OPENAI_BASE_URL=http://localhost:1234/v1
1189
+ OPENAI_MODEL=qwen2.5-coder-7b-instruct # match the model name from LM Studio
1190
+ ```
1191
+
1192
+ **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.
1193
+
1194
+ **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:
1195
+
1196
+ | Model | Size | Why |
1197
+ |-------|------|-----|
1198
+ | `qwen2.5-coder:7b` | ~4.7 GB | Best at code-shaped sessions; trained on programming + tool-use traces |
1199
+ | `llama3.2:3b` | ~2 GB | Smallest sane option — fine for compression, weaker for graph extraction |
1200
+ | `mistral:7b-instruct` | ~4.4 GB | Good general-purpose baseline if you don't want code-specific |
1201
+ | `deepseek-r1:7b` | ~4.7 GB | Reasoning-tier quality at 7B; slower but cleaner extractions |
1202
+
1203
+ 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.
1204
+
1205
+ 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.
1206
+
1207
+ ### Cost-aware model selection
1208
+
1209
+ 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.
1210
+
1211
+ | Tier | Model | Input / 1M | Output / 1M | Cost for the captured 35h | Notes |
1212
+ |------|-------|------------|-------------|---------------------------|-------|
1213
+ | Recommended | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Solid compression + summarization quality at ~10× lower cost than Sonnet. |
1214
+ | Recommended | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Older but still fine for compression-only workloads. |
1215
+ | Recommended | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Strong code reasoning if your sessions are heavily code-shaped. |
1216
+ | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | High quality but expensive for always-on background work. |
1217
+ | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Similar tier to Sonnet. |
1218
+ | Avoid | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Reasoning-class model; massive overspend for compression. |
1219
+
1220
+ 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.
1221
+
1222
+ 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.
1223
+
1224
+ 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/).
1225
+
1226
+ ### Multi-agent memory (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1227
+
1228
+ 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.
1229
+
1230
+ ```env
1231
+ TEAM_ID=company
1232
+ USER_ID=engineering-team
1233
+ AGENT_ID=architect
1234
+ AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1235
+ ```
1236
+
1237
+ Two modes:
1238
+
1239
+ | Mode | Tag writes | Filter recall | When to use |
1240
+ |------|------------|---------------|-------------|
1241
+ | `shared` (default) | yes | no | Cross-agent context with audit trail. Architect can see what developer noted, but every row records who said it. |
1242
+ | `isolated` | yes | yes | Strict separation. Architect never sees developer's observations / memories / sessions. |
1243
+
1244
+ 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.
1245
+
1246
+ 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.
1247
+
1248
+ 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.
1249
+
1250
+ When `AGENT_ID` is unset, memory remains unscoped (legacy behavior, no tags, no filters).
1251
+
1252
+ ### Ports
1253
+
1254
+ 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.
1255
+
1256
+ | Port | Process | Purpose | Env override |
1257
+ |------|---------|---------|--------------|
1258
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1259
+ | `3112` | iii-engine | Internal streams worker (consumed by agentmemory + viewer) | `III_STREAMS_PORT` |
1260
+ | `3113` | agentmemory | Real-time viewer (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1261
+ | `49134` | iii-engine | WebSocket — workers register here, OTel telemetry flows over it | `III_ENGINE_URL` (full URL, default `ws://localhost:49134`) |
1262
+
1263
+ Stale-process cleanup when ports stay bound after a crashed run:
1264
+
1265
+ ```bash
1266
+ # macOS / Linux — find whatever is on each port and kill it
1267
+ lsof -i :3111,3112,3113,49134
1268
+ pkill -f agentmemory || true
1269
+ pkill -f 'iii ' || true
1270
+
1271
+ # Windows
1272
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1273
+ taskkill /F /PID <pid>
1274
+ ```
1275
+
1276
+ `agentmemory stop` reaps both the worker and the engine pidfile cleanly on graceful shutdown (#640, #474). The manual cleanup above is only for the post-crash case where neither pidfile is left behind.
1277
+
1278
+ ### Config File
1279
+
1280
+ 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.
1281
+
1282
+ Process environment variables still work and take precedence over values in the file.
1283
+
1284
+ On Windows, the same file lives at `%USERPROFILE%\.agentmemory\.env`:
1285
+
1286
+ ```powershell
1287
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1288
+ notepad $HOME\.agentmemory\.env
1289
+ ```
1290
+
1291
+ To test with a Claude Code Pro/Max subscription instead of an API key, opt in explicitly:
1292
+
1293
+ ```env
1294
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1295
+ AGENTMEMORY_AUTO_COMPRESS=true
1296
+ ```
1297
+
1298
+ 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:
1299
+
1300
+ ```env
1301
+ GRAPH_EXTRACTION_ENABLED=true
1302
+ # CONSOLIDATION_ENABLED=false # opt out of auto-consolidation
1303
+ ```
1304
+
1050
1305
  ### Environment Variables
1051
1306
 
1052
1307
  Create `~/.agentmemory/.env`:
@@ -1154,7 +1409,7 @@ Create `~/.agentmemory/.env`:
1154
1409
  # Observations are still captured via
1155
1410
  # PostToolUse regardless of this flag.
1156
1411
  # GRAPH_EXTRACTION_ENABLED=false
1157
- # CONSOLIDATION_ENABLED=true
1412
+ # CONSOLIDATION_ENABLED=false # on by default when an LLM provider is configured
1158
1413
  # LESSON_DECAY_ENABLED=true
1159
1414
  # OBSIDIAN_AUTO_EXPORT=false
1160
1415
  # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
@@ -1166,7 +1421,7 @@ Create `~/.agentmemory/.env`:
1166
1421
  # USER_ID=
1167
1422
  # TEAM_MODE=private
1168
1423
 
1169
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1424
+ # Tool visibility: "core" (8 tools, lean fallback) or "all" (53 tools)
1170
1425
  # AGENTMEMORY_TOOLS=core
1171
1426
  ```
1172
1427
 
@@ -1174,7 +1429,7 @@ Create `~/.agentmemory/.env`:
1174
1429
 
1175
1430
  <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>
1176
1431
 
1177
- 124 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.
1432
+ 125 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.
1178
1433
 
1179
1434
  <details>
1180
1435
  <summary>Key endpoints</summary>
package/dist/cli.d.mts CHANGED
@@ -1 +1,5 @@
1
- export { };
1
+ //#region src/cli.d.ts
2
+ declare function discoverViewerPort(): Promise<void>;
3
+ //#endregion
4
+ export { discoverViewerPort };
5
+ //# sourceMappingURL=cli.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.mts","names":[],"sources":["../src/cli.ts"],"mappings":";iBAwMsB,kBAAA,CAAA,GAAsB,OAAA"}