@agentmemory/agentmemory 0.9.20 → 0.9.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +2 -0
- package/README.md +166 -12
- package/dist/.env.example +2 -0
- package/dist/cli.d.mts +5 -1
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +122 -693
- package/dist/cli.mjs.map +1 -1
- package/dist/connect-BQQXpyDS.mjs +763 -0
- package/dist/connect-BQQXpyDS.mjs.map +1 -0
- package/dist/hooks/post-tool-use.mjs +1 -1
- package/dist/hooks/post-tool-use.mjs.map +1 -1
- package/dist/hooks/stop.mjs +8 -0
- package/dist/hooks/stop.mjs.map +1 -1
- package/dist/{image-refs-R3tin9MR.mjs → image-refs-CJS5B9Gq.mjs} +2 -2
- package/dist/{image-refs-R3tin9MR.mjs.map → image-refs-CJS5B9Gq.mjs.map} +1 -1
- package/dist/{image-store-DyrKZKqZ.mjs → image-store-CdE0amb1.mjs} +1 -1
- package/dist/index.mjs +881 -281
- package/dist/index.mjs.map +1 -1
- package/dist/logger-xlVlvCWX.mjs +43 -0
- package/dist/logger-xlVlvCWX.mjs.map +1 -0
- package/dist/schema-BkALl7Z_.mjs +74 -0
- package/dist/schema-BkALl7Z_.mjs.map +1 -0
- package/dist/{src-DPSaLB5-.mjs → src-gpTAJuBy.mjs} +861 -287
- package/dist/src-gpTAJuBy.mjs.map +1 -0
- package/dist/{standalone-DMLk7YxP.mjs → standalone-C4i7ktpn.mjs} +48 -12
- package/dist/standalone-C4i7ktpn.mjs.map +1 -0
- package/dist/standalone.d.mts.map +1 -1
- package/dist/standalone.mjs +45 -10
- package/dist/standalone.mjs.map +1 -1
- package/dist/{tools-registry-Dz8ssuMf.mjs → tools-registry-B7Y6nJsr.mjs} +39 -11
- package/dist/tools-registry-B7Y6nJsr.mjs.map +1 -0
- package/dist/version-DvQMNbEH.mjs +6 -0
- package/dist/version-DvQMNbEH.mjs.map +1 -0
- package/dist/viewer/index.html +134 -21
- package/package.json +6 -4
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.mcp.json +3 -2
- package/plugin/hooks/hooks.codex.json +6 -6
- package/plugin/hooks/hooks.json +12 -12
- package/plugin/opencode/README.md +229 -0
- package/plugin/opencode/agentmemory-capture.ts +687 -0
- package/plugin/opencode/commands/recall.md +19 -0
- package/plugin/opencode/commands/remember.md +19 -0
- package/plugin/opencode/plugin.json +12 -0
- package/plugin/scripts/diagnostics.d.mts +17 -0
- package/plugin/scripts/diagnostics.d.mts.map +1 -0
- package/plugin/scripts/diagnostics.mjs.map +1 -0
- package/plugin/scripts/post-tool-use.mjs +1 -1
- package/plugin/scripts/post-tool-use.mjs.map +1 -1
- package/plugin/scripts/stop.mjs +8 -0
- package/plugin/scripts/stop.mjs.map +1 -1
- package/dist/src-DPSaLB5-.mjs.map +0 -1
- package/dist/standalone-DMLk7YxP.mjs.map +0 -1
- package/dist/tools-registry-Dz8ssuMf.mjs.map +0 -1
package/.env.example
CHANGED
|
@@ -98,6 +98,8 @@
|
|
|
98
98
|
# AGENTMEMORY_GRAPH_WEIGHT=0.2 # Graph traversal bonus on smart-search ranking
|
|
99
99
|
# TOKEN_BUDGET=2000 # Max tokens injected via mem::context per session
|
|
100
100
|
# MAX_OBS_PER_SESSION=500 # Per-session observation cap before consolidation kicks in
|
|
101
|
+
# SUMMARIZE_CHUNK_SIZE=400 # When mem::summarize sees a session larger than this, it chunks observations and map-reduces (chunk-summarize → reduce-merge) to stay within the LLM's context window. Default 400 ≈ 50k tokens per chunk at ~110 tok/obs. Native sessions are capped by MAX_OBS_PER_SESSION; chunking primarily matters for bulk-imported jsonl sessions, which bypass that cap.
|
|
102
|
+
# SUMMARIZE_CHUNK_CONCURRENCY=6 # Parallel chunk LLM calls during chunked summarize. Default 6 fits ~100-chunk sessions under iii's 180s function-invocation timeout at typical ~8s/call. High-throughput providers (Novita, DeepInfra, DeepSeek) commonly allow 100+ concurrent — bump this for very large imported sessions.
|
|
101
103
|
|
|
102
104
|
# -----------------------------------------------------------------------------
|
|
103
105
|
# 5. Behaviour flags
|
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
<p align="center">
|
|
36
36
|
<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>
|
|
37
|
+
<a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
|
|
37
38
|
<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>
|
|
38
39
|
<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>
|
|
39
40
|
<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>
|
|
@@ -72,10 +73,12 @@
|
|
|
72
73
|
## Install
|
|
73
74
|
|
|
74
75
|
```bash
|
|
75
|
-
npm install -g @agentmemory/agentmemory
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
agentmemory
|
|
76
|
+
npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
|
|
77
|
+
# If you hit EACCES on macOS/Linux system Node installs, retry with:
|
|
78
|
+
# sudo npm install -g @agentmemory/agentmemory
|
|
79
|
+
agentmemory # start the memory server on :3111
|
|
80
|
+
agentmemory demo # seed sample sessions + prove recall
|
|
81
|
+
agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
|
|
79
82
|
```
|
|
80
83
|
|
|
81
84
|
Or via `npx` (no install):
|
|
@@ -141,7 +144,7 @@ agentmemory works with any agent that supports hooks, MCP, or REST API. All agen
|
|
|
141
144
|
<td align="center" width="12.5%">
|
|
142
145
|
<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/>
|
|
143
146
|
<strong>OpenCode</strong><br/>
|
|
144
|
-
<sub>MCP
|
|
147
|
+
<sub>22 hooks + MCP + plugin</sub>
|
|
145
148
|
</td>
|
|
146
149
|
<td align="center" width="12.5%">
|
|
147
150
|
<a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
|
|
@@ -207,6 +210,15 @@ npx @agentmemory/agentmemory
|
|
|
207
210
|
|
|
208
211
|
### Retrieval Accuracy
|
|
209
212
|
|
|
213
|
+
**coding-agent-life-v1** (in-house corpus, sandbox-reproducible)
|
|
214
|
+
|
|
215
|
+
| Adapter | P@5 | R@5 | Top-5 hit rate | p50 latency |
|
|
216
|
+
|---|---|---|---|---|
|
|
217
|
+
| **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
|
|
218
|
+
| grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
|
|
219
|
+
|
|
220
|
+
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).
|
|
221
|
+
|
|
210
222
|
**LongMemEval-S** (ICLR 2025, 500 questions)
|
|
211
223
|
|
|
212
224
|
| System | R@5 | R@10 | MRR |
|
|
@@ -232,6 +244,10 @@ npx @agentmemory/agentmemory
|
|
|
232
244
|
|
|
233
245
|
> 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.
|
|
234
246
|
|
|
247
|
+
**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/).
|
|
248
|
+
|
|
249
|
+
**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).
|
|
250
|
+
|
|
235
251
|
---
|
|
236
252
|
|
|
237
253
|
<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>
|
|
@@ -349,6 +365,8 @@ Open `http://localhost:3113` to watch the memory build live.
|
|
|
349
365
|
|
|
350
366
|
```bash
|
|
351
367
|
npm install -g @agentmemory/agentmemory
|
|
368
|
+
# If you hit EACCES on macOS/Linux system Node installs, retry with:
|
|
369
|
+
# sudo npm install -g @agentmemory/agentmemory
|
|
352
370
|
agentmemory # start the server (same as the npx form)
|
|
353
371
|
agentmemory stop # tear it down
|
|
354
372
|
agentmemory remove # uninstall everything we created
|
|
@@ -399,6 +417,19 @@ Implementation details live in `src/cli.ts` (see `runUpgrade` around the `src/cl
|
|
|
399
417
|
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.
|
|
400
418
|
```
|
|
401
419
|
|
|
420
|
+
#### Claude Code without the plugin install (MCP-standalone path)
|
|
421
|
+
|
|
422
|
+
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.21/scripts/…`), so the next upgrade silently breaks every hook ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
|
|
423
|
+
|
|
424
|
+
Workaround:
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
agentmemory connect claude-code --with-hooks
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
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.
|
|
431
|
+
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`.
|
|
432
|
+
|
|
402
433
|
### Codex CLI (Codex plugin platform)
|
|
403
434
|
|
|
404
435
|
```bash
|
|
@@ -407,7 +438,7 @@ npx @agentmemory/agentmemory
|
|
|
407
438
|
|
|
408
439
|
# 2. register the agentmemory marketplace and install the plugin
|
|
409
440
|
codex plugin marketplace add rohitg00/agentmemory
|
|
410
|
-
codex plugin
|
|
441
|
+
codex plugin add agentmemory@agentmemory
|
|
411
442
|
```
|
|
412
443
|
|
|
413
444
|
The Codex plugin ships from the same `plugin/` directory as the Claude Code plugin. It registers:
|
|
@@ -418,6 +449,18 @@ The Codex plugin ships from the same `plugin/` directory as the Claude Code plug
|
|
|
418
449
|
|
|
419
450
|
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.
|
|
420
451
|
|
|
452
|
+
#### Codex Desktop: plugin hooks currently silent (workaround available)
|
|
453
|
+
|
|
454
|
+
`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.
|
|
455
|
+
|
|
456
|
+
Until upstream lands the fix, mirror the same hook commands into the global `~/.codex/hooks.json`:
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
agentmemory connect codex --with-hooks
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
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.
|
|
463
|
+
|
|
421
464
|
<details>
|
|
422
465
|
<summary><b>OpenClaw (paste this prompt)</b></summary>
|
|
423
466
|
|
|
@@ -475,12 +518,13 @@ The agentmemory entry is the **same MCP server block** across every host that us
|
|
|
475
518
|
"command": "npx",
|
|
476
519
|
"args": ["-y", "@agentmemory/mcp"],
|
|
477
520
|
"env": {
|
|
478
|
-
"AGENTMEMORY_URL": "
|
|
521
|
+
"AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
|
|
522
|
+
"AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
|
|
479
523
|
}
|
|
480
524
|
}
|
|
481
525
|
```
|
|
482
526
|
|
|
483
|
-
**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": { ... } }`.
|
|
527
|
+
**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.
|
|
484
528
|
|
|
485
529
|
| Agent | Config file | Notes |
|
|
486
530
|
|---|---|---|
|
|
@@ -491,10 +535,14 @@ The agentmemory entry is the **same MCP server block** across every host that us
|
|
|
491
535
|
| **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (auto-merges). |
|
|
492
536
|
| **OpenClaw** | OpenClaw MCP config | Same `mcpServers` block, or use the deeper [memory plugin](integrations/openclaw/). |
|
|
493
537
|
| **Codex CLI (MCP only)** | `.codex/config.toml` | TOML shape: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, or add `[mcp_servers.agentmemory]` manually. |
|
|
494
|
-
| **Codex CLI (full plugin)** | Codex plugin marketplace | `codex plugin marketplace add rohitg00/agentmemory` then `codex plugin
|
|
495
|
-
| **OpenCode** | `opencode.json` | Different shape — top-level `mcp` key, command as array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
|
|
538
|
+
| **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) + 4 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. |
|
|
539
|
+
| **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}}}`. |
|
|
540
|
+
| **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. |
|
|
496
541
|
| **pi** | `~/.pi/agent/extensions/agentmemory` | Copy [`integrations/pi`](integrations/pi/) and restart pi. |
|
|
497
542
|
| **Hermes Agent** | `~/.hermes/config.yaml` | Use the deeper [memory provider plugin](integrations/hermes/) with `memory.provider: agentmemory`. |
|
|
543
|
+
| **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`. |
|
|
544
|
+
| **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. |
|
|
545
|
+
| **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. |
|
|
498
546
|
| **Goose** | Goose MCP settings UI | Same `mcpServers` block. |
|
|
499
547
|
| **Aider** | n/a | Talk to the REST API directly: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
|
|
500
548
|
| **Any agent (32+)** | n/a | `npx skillkit install agentmemory` auto-detects the host and merges. |
|
|
@@ -890,10 +938,18 @@ OpenCode (`opencode.json`):
|
|
|
890
938
|
"command": ["npx", "-y", "@agentmemory/mcp"],
|
|
891
939
|
"enabled": true
|
|
892
940
|
}
|
|
893
|
-
}
|
|
941
|
+
},
|
|
942
|
+
"plugin": ["./plugins/agentmemory-capture.ts"]
|
|
894
943
|
}
|
|
895
944
|
```
|
|
896
945
|
|
|
946
|
+
Copy the plugin file from the repo:
|
|
947
|
+
```bash
|
|
948
|
+
mkdir -p ~/.config/opencode/plugins
|
|
949
|
+
cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
|
|
950
|
+
cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
|
|
951
|
+
```
|
|
952
|
+
|
|
897
953
|
---
|
|
898
954
|
|
|
899
955
|
<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>
|
|
@@ -1025,7 +1081,7 @@ Full registry: [workers.iii.dev](https://workers.iii.dev). Every worker there co
|
|
|
1025
1081
|
|
|
1026
1082
|
### LLM Providers
|
|
1027
1083
|
|
|
1028
|
-
agentmemory auto-detects from your environment.
|
|
1084
|
+
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.
|
|
1029
1085
|
|
|
1030
1086
|
| Provider | Config | Notes |
|
|
1031
1087
|
|----------|--------|-------|
|
|
@@ -1036,6 +1092,104 @@ agentmemory auto-detects from your environment. No API key needed if you have a
|
|
|
1036
1092
|
| OpenRouter | `OPENROUTER_API_KEY` | Any model |
|
|
1037
1093
|
| 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. |
|
|
1038
1094
|
|
|
1095
|
+
### Cost-aware model selection
|
|
1096
|
+
|
|
1097
|
+
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.
|
|
1098
|
+
|
|
1099
|
+
| Tier | Model | Input / 1M | Output / 1M | Cost for the captured 35h | Notes |
|
|
1100
|
+
|------|-------|------------|-------------|---------------------------|-------|
|
|
1101
|
+
| Recommended | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Solid compression + summarization quality at ~10× lower cost than Sonnet. |
|
|
1102
|
+
| Recommended | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Older but still fine for compression-only workloads. |
|
|
1103
|
+
| Recommended | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Strong code reasoning if your sessions are heavily code-shaped. |
|
|
1104
|
+
| Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | High quality but expensive for always-on background work. |
|
|
1105
|
+
| Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Similar tier to Sonnet. |
|
|
1106
|
+
| Avoid | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Reasoning-class model; massive overspend for compression. |
|
|
1107
|
+
|
|
1108
|
+
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.
|
|
1109
|
+
|
|
1110
|
+
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.
|
|
1111
|
+
|
|
1112
|
+
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/).
|
|
1113
|
+
|
|
1114
|
+
### Multi-agent memory (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
|
|
1115
|
+
|
|
1116
|
+
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.
|
|
1117
|
+
|
|
1118
|
+
```env
|
|
1119
|
+
TEAM_ID=company
|
|
1120
|
+
USER_ID=engineering-team
|
|
1121
|
+
AGENT_ID=architect
|
|
1122
|
+
AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
Two modes:
|
|
1126
|
+
|
|
1127
|
+
| Mode | Tag writes | Filter recall | When to use |
|
|
1128
|
+
|------|------------|---------------|-------------|
|
|
1129
|
+
| `shared` (default) | yes | no | Cross-agent context with audit trail. Architect can see what developer noted, but every row records who said it. |
|
|
1130
|
+
| `isolated` | yes | yes | Strict separation. Architect never sees developer's observations / memories / sessions. |
|
|
1131
|
+
|
|
1132
|
+
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.
|
|
1133
|
+
|
|
1134
|
+
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.
|
|
1135
|
+
|
|
1136
|
+
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.
|
|
1137
|
+
|
|
1138
|
+
When `AGENT_ID` is unset, memory remains unscoped (legacy behavior, no tags, no filters).
|
|
1139
|
+
|
|
1140
|
+
### Ports
|
|
1141
|
+
|
|
1142
|
+
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.
|
|
1143
|
+
|
|
1144
|
+
| Port | Process | Purpose | Env override |
|
|
1145
|
+
|------|---------|---------|--------------|
|
|
1146
|
+
| `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
|
|
1147
|
+
| `3112` | iii-engine | Internal streams worker (consumed by agentmemory + viewer) | `III_STREAMS_PORT` |
|
|
1148
|
+
| `3113` | agentmemory | Real-time viewer (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
|
|
1149
|
+
| `49134` | iii-engine | WebSocket — workers register here, OTel telemetry flows over it | `III_ENGINE_URL` (full URL, default `ws://localhost:49134`) |
|
|
1150
|
+
|
|
1151
|
+
Stale-process cleanup when ports stay bound after a crashed run:
|
|
1152
|
+
|
|
1153
|
+
```bash
|
|
1154
|
+
# macOS / Linux — find whatever is on each port and kill it
|
|
1155
|
+
lsof -i :3111,3112,3113,49134
|
|
1156
|
+
pkill -f agentmemory || true
|
|
1157
|
+
pkill -f 'iii ' || true
|
|
1158
|
+
|
|
1159
|
+
# Windows
|
|
1160
|
+
netstat -ano | findstr ":3111 :3112 :3113 :49134"
|
|
1161
|
+
taskkill /F /PID <pid>
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
`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.
|
|
1165
|
+
|
|
1166
|
+
### Config File
|
|
1167
|
+
|
|
1168
|
+
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.
|
|
1169
|
+
|
|
1170
|
+
Process environment variables still work and take precedence over values in the file.
|
|
1171
|
+
|
|
1172
|
+
On Windows, the same file lives at `%USERPROFILE%\.agentmemory\.env`:
|
|
1173
|
+
|
|
1174
|
+
```powershell
|
|
1175
|
+
New-Item -ItemType Directory -Force $HOME\.agentmemory
|
|
1176
|
+
notepad $HOME\.agentmemory\.env
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
To test with a Claude Code Pro/Max subscription instead of an API key, opt in explicitly:
|
|
1180
|
+
|
|
1181
|
+
```env
|
|
1182
|
+
AGENTMEMORY_ALLOW_AGENT_SDK=true
|
|
1183
|
+
AGENTMEMORY_AUTO_COMPRESS=true
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1186
|
+
Turn on graph or consolidation features in the same file if you want them:
|
|
1187
|
+
|
|
1188
|
+
```env
|
|
1189
|
+
GRAPH_EXTRACTION_ENABLED=true
|
|
1190
|
+
CONSOLIDATION_ENABLED=true
|
|
1191
|
+
```
|
|
1192
|
+
|
|
1039
1193
|
### Environment Variables
|
|
1040
1194
|
|
|
1041
1195
|
Create `~/.agentmemory/.env`:
|
package/dist/.env.example
CHANGED
|
@@ -98,6 +98,8 @@
|
|
|
98
98
|
# AGENTMEMORY_GRAPH_WEIGHT=0.2 # Graph traversal bonus on smart-search ranking
|
|
99
99
|
# TOKEN_BUDGET=2000 # Max tokens injected via mem::context per session
|
|
100
100
|
# MAX_OBS_PER_SESSION=500 # Per-session observation cap before consolidation kicks in
|
|
101
|
+
# SUMMARIZE_CHUNK_SIZE=400 # When mem::summarize sees a session larger than this, it chunks observations and map-reduces (chunk-summarize → reduce-merge) to stay within the LLM's context window. Default 400 ≈ 50k tokens per chunk at ~110 tok/obs. Native sessions are capped by MAX_OBS_PER_SESSION; chunking primarily matters for bulk-imported jsonl sessions, which bypass that cap.
|
|
102
|
+
# SUMMARIZE_CHUNK_CONCURRENCY=6 # Parallel chunk LLM calls during chunked summarize. Default 6 fits ~100-chunk sessions under iii's 180s function-invocation timeout at typical ~8s/call. High-throughput providers (Novita, DeepInfra, DeepSeek) commonly allow 100+ concurrent — bump this for very large imported sessions.
|
|
101
103
|
|
|
102
104
|
# -----------------------------------------------------------------------------
|
|
103
105
|
# 5. Behaviour flags
|
package/dist/cli.d.mts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.mts","names":[],"sources":["../src/cli.ts"],"mappings":";iBAuMsB,kBAAA,CAAA,GAAsB,OAAA"}
|