Skip to content

#1 Persistent memory for AI coding agents based on real-world benchmarks

fix: guard hooks against null payload (#1074)

Rohit Ghumare6761a99ba1e6
diff --git a/AGENTS.md b/AGENTS.md
index 873ef10f..ead439f1 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -109,16 +109,16 @@ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import).
## Testing
-- All tests must pass before PR: `npm test` (950+ tests)
+- All tests must pass before PR: `npm test` (1,428+ tests)
- Mock pattern: `vi.mock("iii-sdk")` with mock `sdk.trigger`, `kv.get/set/list`
- Test files go in `test/` with `.test.ts` extension
- Follow existing patterns in `test/crystallize.test.ts` for function tests
-## Current Stats (v0.9.16)
+## Current Stats (v0.9.28)
- 53 MCP tools (8 visible by default, `AGENTMEMORY_TOOLS=all` for all)
- 128 REST endpoints
- 6 MCP resources, 3 MCP prompts
- 12 hooks, 15 skills
-- 50+ iii functions
-- 950+ tests
+- 260+ iii functions
+- 1,428+ tests
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b5188fa..24a1722e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## [Unreleased]
+## [0.9.28] — 2026-07-19
+
+Patch release: hardens the hook runner against malformed payloads and closes a cross-agent context leak. No breaking changes; drop-in upgrade.
+
+### Security
+
+- **Cross-agent memory leak via `POST /agentmemory/context`** ([#1057](https://github.com/rohitg00/agentmemory/issues/1057)). `mem::context` and its `api::context` handler filtered candidate sessions by `project` only, so under `AGENTMEMORY_AGENT_SCOPE=isolated` one profile could receive another profile's session observations and summaries whenever they shared a project path — while `/search` and `/smart-search` already filtered correctly. `mem::context` now applies the same agent-scope filter as `mem::search` ([#817](https://github.com/rohitg00/agentmemory/issues/817)): explicit `agentId` pins, wildcard `agentId: "*"` bypasses, isolated mode falls back to env `AGENT_ID`, and the call fails closed if isolated mode is on with no resolvable agent id. All three callers (`api::context`, `api::session::start`, `event::session::started`) now forward `agentId`.
+
+### Fixed
+
+- **Hooks crashed with exit code 1 on a `null` JSON payload** ([#1047](https://github.com/rohitg00/agentmemory/issues/1047)). `JSON.parse("null")` returns `null` without throwing, so the existing parse guard passed it through and the first `data.session_id` access threw a `TypeError`. Because each hook called `main()` bare, that became an unhandled rejection and the host CLI (Codex CLI, Claude Code) reported "hook exited with code 1" on every affected tool call. All 13 hook entrypoints now guard `if (!data || typeof data !== "object")` before dereferencing, and wrap the top-level `main()` in `.catch()` so any hook error fails closed (silent exit 0) instead of surfacing to the host tool loop.
+
+### Docs
+
+- Refreshed stale stats in README and AGENTS.md (AGENTS test count 950+ → 1,428+, iii-function count 50+ → 260+) plus the README source-file, LOC, function, and KV-scope counts, and regenerated the website meta snapshot for 0.9.28. Removed the rate-limited star-history chart from the README and all 11 translations.
+
## [0.9.27] — 2026-06-07
Wave release closing several breaking regressions reported against v0.9.26, plus an agent-scope isolation security fix, an iii version-pin audit fix, and a benchmark scorecard correction. No breaking changes; drop-in upgrade.
@@ -50,6 +66,7 @@ Wave release closing several breaking regressions reported against v0.9.26, plus
- `/agentmemory:forget` skill still calls `memory_governance_delete` which only touches `KV.memories` and never observations ([#833](https://github.com/rohitg00/agentmemory/issues/833)). Skill rewrite + new `memory_forget` MCP tool tracked separately.
- `crypto.randomUUID()` global-only on Node <19 ([#715](https://github.com/rohitg00/agentmemory/issues/715)). Drop-in import fix tracked.
+[0.9.28]: https://github.com/rohitg00/agentmemory/compare/v0.9.27...v0.9.28
[0.9.27]: https://github.com/rohitg00/agentmemory/compare/v0.9.26...v0.9.27
## [0.9.26] — 2026-06-03
diff --git a/README.md b/README.md
index d04da371..84d747f9 100644
--- a/README.md
+++ b/README.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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>
</p>
@@ -60,7 +50,7 @@
<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>
<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>
<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>
- <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>
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tests.svg"><img src="assets/tags/stat-tests.svg" alt="1,428+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1211,7 +1201,7 @@ Full registry: [workers.iii.dev](https://workers.iii.dev). Every worker there co
| Prometheus / Grafana | iii OTEL + health monitor |
| Custom plugin systems | `iii worker add <name>` |
-**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.
+**175 source files · ~39,200 LOC · 1,428+ tests · 261 functions · 52 KV scopes** — all on three primitives. No `agentmemory plugin install`. The plugin system is iii itself.
---
@@ -1535,7 +1525,7 @@ Full endpoint list: [`src/triggers/api.ts`](src/triggers/api.ts)
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 1,423+ tests
+npm test # 1,428+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.de-DE.md b/READMEs/README.de-DE.md
index 8d92f8af..512e81d8 100644
--- a/READMEs/README.de-DE.md
+++ b/READMEs/README.de-DE.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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-Dokument: 1200 stars / 172 forks im Gist" /></a>
</p>
diff --git a/READMEs/README.es-ES.md b/READMEs/README.es-ES.md
index 3245e211..8b5654ea 100644
--- a/READMEs/README.es-ES.md
+++ b/READMEs/README.es-ES.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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="Documento de diseño: 1200 stars / 172 forks en el gist" /></a>
</p>
diff --git a/READMEs/README.fr-FR.md b/READMEs/README.fr-FR.md
index b72b503f..d00206cb 100644
--- a/READMEs/README.fr-FR.md
+++ b/READMEs/README.fr-FR.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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="Document de conception : 1200 stars / 172 forks sur le gist" /></a>
</p>
diff --git a/READMEs/README.hi-IN.md b/READMEs/README.hi-IN.md
index 00358fad..8733236a 100644
--- a/READMEs/README.hi-IN.md
+++ b/READMEs/README.hi-IN.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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>
</p>
diff --git a/READMEs/README.ja-JP.md b/READMEs/README.ja-JP.md
index 979094f6..30d535d9 100644
--- a/READMEs/README.ja-JP.md
+++ b/READMEs/README.ja-JP.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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>
</p>
diff --git a/READMEs/README.ko-KR.md b/READMEs/README.ko-KR.md
index 369797c3..395c91c2 100644
--- a/READMEs/README.ko-KR.md
+++ b/READMEs/README.ko-KR.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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="설계 문서: gist 기준 1200 stars / 172 forks" /></a>
</p>
diff --git a/READMEs/README.pt-BR.md b/READMEs/README.pt-BR.md
index e9bbc32e..0e80ff8f 100644
--- a/READMEs/README.pt-BR.md
+++ b/READMEs/README.pt-BR.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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="Documento de design: 1200 stars / 172 forks no gist" /></a>
</p>
diff --git a/READMEs/README.ru-RU.md b/READMEs/README.ru-RU.md
index 804f380c..f6c1e554 100644
--- a/READMEs/README.ru-RU.md
+++ b/READMEs/README.ru-RU.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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="Документ проекта: 1200 звёзд / 172 форка в гисте" /></a>
</p>
diff --git a/READMEs/README.tr-TR.md b/READMEs/README.tr-TR.md
index 28fad807..fefcf6cc 100644
--- a/READMEs/README.tr-TR.md
+++ b/READMEs/README.tr-TR.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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>
</p>
diff --git a/READMEs/README.zh-CN.md b/READMEs/README.zh-CN.md
index e711a367..a11ab29a 100644
--- a/READMEs/README.zh-CN.md
+++ b/READMEs/README.zh-CN.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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>
</p>
diff --git a/READMEs/README.zh-TW.md b/READMEs/README.zh-TW.md
index 75b2fc97..c7a20fb5 100644
--- a/READMEs/README.zh-TW.md
+++ b/READMEs/README.zh-TW.md
@@ -29,16 +29,6 @@
<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>
</p>
-<p align="center">
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
- </picture>
- </a>
-</p>
-
<p align="center">
<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>
</p>
diff --git a/assets/tags/light/stat-tests.svg b/assets/tags/light/stat-tests.svg
index 5025673f..a309d2c7 100644
--- a/assets/tags/light/stat-tests.svg
+++ b/assets/tags/light/stat-tests.svg
@@ -1,5 +1,5 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 48" fill="none" role="img" aria-label="TESTS PASSING: 1390+">
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 48" fill="none" role="img" aria-label="TESTS PASSING: 1428+">
<rect x="0" y="0" width="140" height="48" rx="10" fill="#FFFFFF" stroke="#E5E7EB" stroke-width="1"/>
- <text x="70" y="24" fill="#16A34A" font-family='ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif' font-size="18" font-weight="900" text-anchor="middle" letter-spacing="-0.3">1390+</text>
+ <text x="70" y="24" fill="#16A34A" font-family='ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif' font-size="18" font-weight="900" text-anchor="middle" letter-spacing="-0.3">1428+</text>
<text x="70" y="38" fill="#64748B" font-family='ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif' font-size="9" font-weight="600" text-anchor="middle" letter-spacing="1.5">TESTS PASSING</text>
</svg>
diff --git a/assets/tags/stat-tests.svg b/assets/tags/stat-tests.svg
index 7dc0f78d..4b2dfe07 100644
--- a/assets/tags/stat-tests.svg
+++ b/assets/tags/stat-tests.svg
@@ -1,5 +1,5 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 48" fill="none" role="img" aria-label="TESTS PASSING: 1390+">
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 48" fill="none" role="img" aria-label="TESTS PASSING: 1428+">
<rect x="0" y="0" width="140" height="48" rx="10" fill="#1A1A1A" stroke="#2A2A2A" stroke-width="1"/>
- <text x="70" y="24" fill="#00D26A" font-family='ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif' font-size="18" font-weight="900" text-anchor="middle" letter-spacing="-0.3">1390+</text>
+ <text x="70" y="24" fill="#00D26A" font-family='ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif' font-size="18" font-weight="900" text-anchor="middle" letter-spacing="-0.3">1428+</text>
<text x="70" y="38" fill="#9CA3AF" font-family='ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif' font-size="9" font-weight="600" text-anchor="middle" letter-spacing="1.5">TESTS PASSING</text>
</svg>
diff --git a/deploy/coolify/Dockerfile b/deploy/coolify/Dockerfile
index 48c8d59d..e95bd70e 100644
--- a/deploy/coolify/Dockerfile
+++ b/deploy/coolify/Dockerfile
@@ -4,7 +4,7 @@ FROM iiidev/iii:${III_VERSION} AS iii-image
FROM node:22-slim
-ARG AGENTMEMORY_VERSION=0.9.27
+ARG AGENTMEMORY_VERSION=0.9.28
ARG III_VERSION=0.11.2
ARG III_SDK_VERSION=0.11.2
diff --git a/deploy/coolify/docker-compose.yml b/deploy/coolify/docker-compose.yml
index 73d53661..c2f93ab9 100644
--- a/deploy/coolify/docker-compose.yml
+++ b/deploy/coolify/docker-compose.yml
@@ -4,7 +4,7 @@ services:
context: .
dockerfile: Dockerfile
args:
- AGENTMEMORY_VERSION: "0.9.27"
+ AGENTMEMORY_VERSION: "0.9.28"
III_VERSION: "0.11.2"
III_SDK_VERSION: "0.11.2"
restart: unless-stopped
diff --git a/deploy/fly/Dockerfile b/deploy/fly/Dockerfile
index 3769815d..51da03a4 100644
--- a/deploy/fly/Dockerfile
+++ b/deploy/fly/Dockerfile
@@ -4,7 +4,7 @@ FROM iiidev/iii:${III_VERSION} AS iii-image
FROM node:22-slim
-ARG AGENTMEMORY_VERSION=0.9.27
+ARG AGENTMEMORY_VERSION=0.9.28
ARG III_VERSION=0.11.2
ARG III_SDK_VERSION=0.11.2
diff --git a/deploy/railway/Dockerfile b/deploy/railway/Dockerfile
index 3769815d..51da03a4 100644
--- a/deploy/railway/Dockerfile
+++ b/deploy/railway/Dockerfile
@@ -4,7 +4,7 @@ FROM iiidev/iii:${III_VERSION} AS iii-image
FROM node:22-slim
-ARG AGENTMEMORY_VERSION=0.9.27
+ARG AGENTMEMORY_VERSION=0.9.28
ARG III_VERSION=0.11.2
ARG III_SDK_VERSION=0.11.2
diff --git a/deploy/render/Dockerfile b/deploy/render/Dockerfile
index 3769815d..51da03a4 100644
--- a/deploy/render/Dockerfile
+++ b/deploy/render/Dockerfile
@@ -4,7 +4,7 @@ FROM iiidev/iii:${III_VERSION} AS iii-image
FROM node:22-slim
-ARG AGENTMEMORY_VERSION=0.9.27
+ARG AGENTMEMORY_VERSION=0.9.28
ARG III_VERSION=0.11.2
ARG III_SDK_VERSION=0.11.2
diff --git a/deploy/render/render.yaml b/deploy/render/render.yaml
index d2694693..b2333805 100644
--- a/deploy/render/render.yaml
+++ b/deploy/render/render.yaml
@@ -15,7 +15,7 @@ services:
- key: PORT
value: "3111"
- key: AGENTMEMORY_VERSION
- value: "0.9.27"
+ value: "0.9.28"
- key: III_VERSION
value: "0.11.2"
- key: III_SDK_VERSION
diff --git a/package.json b/package.json
index 4e2bc8c4..588e94da 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@agentmemory/agentmemory",
- "version": "0.9.27",
+ "version": "0.9.28",
"description": "Persistent memory for AI coding agents, powered by iii-engine's three primitives",
"type": "module",
"main": "dist/index.mjs",
diff --git a/packages/mcp/package.json b/packages/mcp/package.json
index e918d9cb..bdc31203 100644
--- a/packages/mcp/package.json
+++ b/packages/mcp/package.json
@@ -1,6 +1,6 @@
{
"name": "@agentmemory/mcp",
- "version": "0.9.27",
+ "version": "0.9.28",
"description": "Standalone MCP server for agentmemory — thin shim that re-exposes @agentmemory/agentmemory's MCP entrypoint",
"type": "module",
"bin": {
diff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.json
index cb4e6df7..49d4bacb 100644
--- a/plugin/.claude-plugin/plugin.json
+++ b/plugin/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "agentmemory",
- "version": "0.9.27",
+ "version": "0.9.28",
"description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 53 MCP tools, 8 skills, real-time viewer.",
"author": {
"name": "Rohit Ghumare",
diff --git a/plugin/.codex-plugin/plugin.json b/plugin/.codex-plugin/plugin.json
index 7c42f130..9d350289 100644
--- a/plugin/.codex-plugin/plugin.json
+++ b/plugin/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "agentmemory",
- "version": "0.9.27",
+ "version": "0.9.28",
"description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 6 hooks, 53 MCP tools, 8 skills, real-time viewer.",
"author": {
"name": "Rohit Ghumare",
diff --git a/plugin/plugin.json b/plugin/plugin.json
index 9d0751a7..7d9cfca1 100644
--- a/plugin/plugin.json
+++ b/plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "agentmemory",
- "version": "0.9.27",
+ "version": "0.9.28",
"description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 53 MCP tools, 15 skills, real-time viewer.",
"author": {
"name": "Rohit Ghumare",
diff --git a/plugin/scripts/notification.mjs b/plugin/scripts/notification.mjs
index 3967158c..0a814e89 100755
--- a/plugin/scripts/notification.mjs
+++ b/plugin/scripts/notification.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { basename } from "node:path";
-
//#region src/hooks/_project.ts
function resolveProject(cwd) {
const explicit = process.env["AGENTMEMORY_PROJECT_NAME"];
@@ -21,7 +20,6 @@ function resolveProject(cwd) {
} catch {}
return basename(dir);
}
-
//#endregion
//#region src/hooks/notification.ts
function isSdkChildContext(payload) {
@@ -45,6 +43,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const notificationType = data.notification_type ?? data.notificationType;
if (notificationType !== "permission_prompt") return;
@@ -69,8 +68,8 @@ async function main() {
}).catch(() => {});
setTimeout(() => process.exit(0), 500).unref();
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=notification.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/post-commit.mjs b/plugin/scripts/post-commit.mjs
index 8552cd61..04cc6236 100755
--- a/plugin/scripts/post-commit.mjs
+++ b/plugin/scripts/post-commit.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execFile } from "node:child_process";
import { promisify } from "node:util";
-
//#region src/hooks/post-commit.ts
const exec = promisify(execFile);
function isSdkChildContext(payload) {
@@ -35,6 +34,7 @@ async function main() {
if (input.trim()) try {
data = JSON.parse(input);
} catch {}
+ if (!data || typeof data !== "object") data = {};
if (isSdkChildContext(data)) return;
const cwd = data.cwd || process.env["AGENTMEMORY_CWD"] || process.cwd();
const sessionId = data.session_id || process.env["AGENTMEMORY_SESSION_ID"] || void 0;
@@ -95,8 +95,8 @@ async function main() {
});
} catch {}
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=post-commit.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/post-tool-failure.mjs b/plugin/scripts/post-tool-failure.mjs
index 6fdad8d9..18782a56 100755
--- a/plugin/scripts/post-tool-failure.mjs
+++ b/plugin/scripts/post-tool-failure.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { basename } from "node:path";
-
//#region src/hooks/_project.ts
function resolveProject(cwd) {
const explicit = process.env["AGENTMEMORY_PROJECT_NAME"];
@@ -21,7 +20,6 @@ function resolveProject(cwd) {
} catch {}
return basename(dir);
}
-
//#endregion
//#region src/hooks/post-tool-failure.ts
function isSdkChildContext(payload) {
@@ -45,6 +43,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
if (data.is_interrupt || data.isInterrupt) return;
const sessionId = data.session_id || data.sessionId || "unknown";
@@ -70,8 +69,8 @@ async function main() {
}).catch(() => {});
setTimeout(() => process.exit(0), 500).unref();
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=post-tool-failure.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/post-tool-use.mjs b/plugin/scripts/post-tool-use.mjs
index b4aef9c9..53853ee1 100755
--- a/plugin/scripts/post-tool-use.mjs
+++ b/plugin/scripts/post-tool-use.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { basename } from "node:path";
-
//#region src/hooks/_project.ts
function resolveProject(cwd) {
const explicit = process.env["AGENTMEMORY_PROJECT_NAME"];
@@ -21,7 +20,6 @@ function resolveProject(cwd) {
} catch {}
return basename(dir);
}
-
//#endregion
//#region src/hooks/post-tool-use.ts
function isSdkChildContext(payload) {
@@ -45,6 +43,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = data.session_id || data.sessionId || "unknown";
const toolName = data.tool_name ?? data.toolName;
@@ -115,8 +114,8 @@ function truncate(value, max) {
}
return value;
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=post-tool-use.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/pre-compact.mjs b/plugin/scripts/pre-compact.mjs
index 0afdcb0b..c4b8cea1 100755
--- a/plugin/scripts/pre-compact.mjs
+++ b/plugin/scripts/pre-compact.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { basename } from "node:path";
-
//#region src/hooks/_project.ts
function resolveProject(cwd) {
const explicit = process.env["AGENTMEMORY_PROJECT_NAME"];
@@ -21,7 +20,6 @@ function resolveProject(cwd) {
} catch {}
return basename(dir);
}
-
//#endregion
//#region src/hooks/pre-compact.ts
function isSdkChildContext(payload) {
@@ -45,6 +43,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = data.session_id || data.sessionId || "unknown";
const project = resolveProject(data.cwd);
@@ -73,8 +72,8 @@ async function main() {
}
} catch {}
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=pre-compact.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/pre-tool-use.mjs b/plugin/scripts/pre-tool-use.mjs
index d70c166e..ad1094a1 100755
--- a/plugin/scripts/pre-tool-use.mjs
+++ b/plugin/scripts/pre-tool-use.mjs
@@ -23,6 +23,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const toolName = typeof data.tool_name === "string" ? data.tool_name : typeof data.toolName === "string" ? data.toolName : void 0;
if (!toolName) return;
@@ -77,8 +78,8 @@ async function main() {
}
} catch {}
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=pre-tool-use.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/prompt-submit.mjs b/plugin/scripts/prompt-submit.mjs
index 1a4147e6..3bb271ae 100755
--- a/plugin/scripts/prompt-submit.mjs
+++ b/plugin/scripts/prompt-submit.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { basename } from "node:path";
-
//#region src/hooks/_project.ts
function resolveProject(cwd) {
const explicit = process.env["AGENTMEMORY_PROJECT_NAME"];
@@ -21,7 +20,6 @@ function resolveProject(cwd) {
} catch {}
return basename(dir);
}
-
//#endregion
//#region src/hooks/prompt-submit.ts
function isSdkChildContext(payload) {
@@ -45,6 +43,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = data.session_id || data.sessionId || "unknown";
fetch(`${REST_URL}/agentmemory/observe`, {
@@ -62,8 +61,8 @@ async function main() {
}).catch(() => {});
setTimeout(() => process.exit(0), 500).unref();
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=prompt-submit.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/session-end.mjs b/plugin/scripts/session-end.mjs
index 019149c3..811c1c26 100755
--- a/plugin/scripts/session-end.mjs
+++ b/plugin/scripts/session-end.mjs
@@ -21,6 +21,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = data.session_id || data.sessionId || "unknown";
fetch(`${REST_URL}/agentmemory/session/end`, {
@@ -53,8 +54,8 @@ async function main() {
}).catch(() => {});
setTimeout(() => process.exit(0), 1500).unref();
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=session-end.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/session-start.mjs b/plugin/scripts/session-start.mjs
index 51b70eb4..8c1bb647 100755
--- a/plugin/scripts/session-start.mjs
+++ b/plugin/scripts/session-start.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { basename } from "node:path";
-
//#region src/hooks/_project.ts
function resolveProject(cwd) {
const explicit = process.env["AGENTMEMORY_PROJECT_NAME"];
@@ -21,7 +20,6 @@ function resolveProject(cwd) {
} catch {}
return basename(dir);
}
-
//#endregion
//#region src/hooks/session-start.ts
function isSdkChildContext(payload) {
@@ -48,6 +46,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = data.session_id || data.sessionId || `ses_${Date.now().toString(36)}`;
const cwd = data.cwd || process.cwd();
@@ -80,8 +79,8 @@ async function main() {
}
} catch {}
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=session-start.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/stop.mjs b/plugin/scripts/stop.mjs
index 03d30c64..0b1c43b0 100755
--- a/plugin/scripts/stop.mjs
+++ b/plugin/scripts/stop.mjs
@@ -21,6 +21,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = data.session_id || data.sessionId || "unknown";
fetch(`${REST_URL}/agentmemory/summarize`, {
@@ -37,8 +38,8 @@ async function main() {
}).catch(() => {});
setTimeout(() => process.exit(0), 1500).unref();
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=stop.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/subagent-start.mjs b/plugin/scripts/subagent-start.mjs
index 2359a1c6..a089ae3d 100755
--- a/plugin/scripts/subagent-start.mjs
+++ b/plugin/scripts/subagent-start.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { basename } from "node:path";
-
//#region src/hooks/_project.ts
function resolveProject(cwd) {
const explicit = process.env["AGENTMEMORY_PROJECT_NAME"];
@@ -21,7 +20,6 @@ function resolveProject(cwd) {
} catch {}
return basename(dir);
}
-
//#endregion
//#region src/hooks/subagent-start.ts
function isSdkChildContext(payload) {
@@ -46,6 +44,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = data.session_id || data.sessionId || "unknown";
const agentId = data.agent_id || data.agentName;
@@ -68,8 +67,8 @@ async function main() {
}).catch(() => {});
setTimeout(() => process.exit(0), 500).unref();
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=subagent-start.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/subagent-stop.mjs b/plugin/scripts/subagent-stop.mjs
index 2ba1b002..4e00f9d7 100755
--- a/plugin/scripts/subagent-stop.mjs
+++ b/plugin/scripts/subagent-stop.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { basename } from "node:path";
-
//#region src/hooks/_project.ts
function resolveProject(cwd) {
const explicit = process.env["AGENTMEMORY_PROJECT_NAME"];
@@ -21,7 +20,6 @@ function resolveProject(cwd) {
} catch {}
return basename(dir);
}
-
//#endregion
//#region src/hooks/subagent-stop.ts
function isSdkChildContext(payload) {
@@ -45,6 +43,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = data.session_id || data.sessionId || "unknown";
const agentId = data.agent_id || data.agentName;
@@ -69,8 +68,8 @@ async function main() {
}).catch(() => {});
setTimeout(() => process.exit(0), 500).unref();
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=subagent-stop.mjs.map
\ No newline at end of file
diff --git a/plugin/scripts/task-completed.mjs b/plugin/scripts/task-completed.mjs
index 478f0688..e8a5bfcc 100755
--- a/plugin/scripts/task-completed.mjs
+++ b/plugin/scripts/task-completed.mjs
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { execSync } from "node:child_process";
import { basename } from "node:path";
-
//#region src/hooks/_project.ts
function resolveProject(cwd) {
const explicit = process.env["AGENTMEMORY_PROJECT_NAME"];
@@ -21,7 +20,6 @@ function resolveProject(cwd) {
} catch {}
return basename(dir);
}
-
//#endregion
//#region src/hooks/task-completed.ts
function isSdkChildContext(payload) {
@@ -45,6 +43,7 @@ async function main() {
} catch {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = data.session_id || "unknown";
fetch(`${REST_URL}/agentmemory/observe`, {
@@ -68,8 +67,8 @@ async function main() {
}).catch(() => {});
setTimeout(() => process.exit(0), 500).unref();
}
-main();
-
+main().catch(() => process.exit(0));
//#endregion
-export { };
+export {};
+
//# sourceMappingURL=task-completed.mjs.map
\ No newline at end of file
diff --git a/src/functions/context.ts b/src/functions/context.ts
index 1e6102cf..97ce18e3 100644
--- a/src/functions/context.ts
+++ b/src/functions/context.ts
@@ -17,6 +17,7 @@ import {
listPinnedSlots,
renderPinnedContext,
} from "./slots.js";
+import { getAgentId, isAgentScopeIsolated } from "../config.js";
function estimateTokens(text: string): number {
return Math.ceil(text.length / 3);
@@ -36,10 +37,39 @@ export function registerContextFunction(
tokenBudget: number,
): void {
sdk.registerFunction("mem::context",
- async (data: { sessionId: string; project: string; budget?: number }) => {
+ async (data: {
+ sessionId: string;
+ project: string;
+ budget?: number;
+ agentId?: string;
+ }) => {
const budget = data.budget || tokenBudget;
const blocks: ContextBlock[] = [];
+ // Cross-agent isolation for the injected-context path. Mirrors the
+ // filter mem::search / mem::smart-search already apply so /context
+ // cannot leak another profile's sessions. Fail-closed: if isolated
+ // mode is on with no explicit agentId and env AGENT_ID unset, refuse
+ // rather than silently returning cross-agent rows.
+ const isolated = isAgentScopeIsolated();
+ const explicitAgentId =
+ typeof data.agentId === "string" && data.agentId.trim().length > 0
+ ? data.agentId.trim()
+ : undefined;
+ const wildcardAgent = explicitAgentId === "*";
+ const envAgentId = isolated ? getAgentId() : undefined;
+ const filterAgentId = wildcardAgent
+ ? undefined
+ : explicitAgentId ?? envAgentId;
+ if (isolated && !wildcardAgent && !explicitAgentId && !envAgentId) {
+ throw new Error(
+ "mem::context: AGENTMEMORY_AGENT_SCOPE=isolated is set but no " +
+ "agent id is available (env AGENT_ID unset and no explicit " +
+ "agentId in the call). Refusing to read cross-agent rows. " +
+ 'Pass agentId: "*" to opt in to a wildcard read.',
+ );
+ }
+
const [pinnedSlots, profile, lessons] = await Promise.all([
isSlotsEnabled()
? listPinnedSlots(kv).catch(() => [] as MemorySlot[])
@@ -134,7 +164,12 @@ export function registerContextFunction(
const allSessions = await kv.list<Session>(KV.sessions);
const sessions = allSessions
- .filter((s) => s.project === data.project && s.id !== data.sessionId)
+ .filter(
+ (s) =>
+ s.project === data.project &&
+ s.id !== data.sessionId &&
+ (filterAgentId === undefined || s.agentId === filterAgentId),
+ )
.sort(
(a, b) =>
new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime(),
diff --git a/src/functions/export-import.ts b/src/functions/export-import.ts
index 327117b2..8b3bc7cc 100644
--- a/src/functions/export-import.ts
+++ b/src/functions/export-import.ts
@@ -176,7 +176,7 @@ export function registerExportImportFunction(sdk: ISdk, kv: StateKV): void {
const strategy = data.strategy || "merge";
const importData = data.exportData;
- const supportedVersions = new Set(["0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.7.0", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6", "0.8.7", "0.8.8", "0.8.9", "0.8.10", "0.8.11", "0.8.12", "0.8.13", "0.9.0", "0.9.1", "0.9.2", "0.9.3", "0.9.4", "0.9.5", "0.9.6", "0.9.7", "0.9.8", "0.9.9", "0.9.10", "0.9.11", "0.9.12", "0.9.13", "0.9.14", "0.9.15", "0.9.16", "0.9.17", "0.9.18", "0.9.19", "0.9.20", "0.9.21", "0.9.22", "0.9.23", "0.9.24", "0.9.25", "0.9.26", "0.9.27"]);
+ const supportedVersions = new Set(["0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.7.0", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6", "0.8.7", "0.8.8", "0.8.9", "0.8.10", "0.8.11", "0.8.12", "0.8.13", "0.9.0", "0.9.1", "0.9.2", "0.9.3", "0.9.4", "0.9.5", "0.9.6", "0.9.7", "0.9.8", "0.9.9", "0.9.10", "0.9.11", "0.9.12", "0.9.13", "0.9.14", "0.9.15", "0.9.16", "0.9.17", "0.9.18", "0.9.19", "0.9.20", "0.9.21", "0.9.22", "0.9.23", "0.9.24", "0.9.25", "0.9.26", "0.9.27", "0.9.28"]);
if (!supportedVersions.has(importData.version)) {
return {
success: false,
diff --git a/src/hooks/notification.ts b/src/hooks/notification.ts
index 9ad77042..af3075ab 100644
--- a/src/hooks/notification.ts
+++ b/src/hooks/notification.ts
@@ -29,6 +29,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const notificationType = data.notification_type ?? data.notificationType;
if (notificationType !== "permission_prompt") return;
@@ -59,4 +60,4 @@ async function main() {
setTimeout(() => process.exit(0), 500).unref();
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/post-commit.ts b/src/hooks/post-commit.ts
index 30c54a9a..70a01fc7 100644
--- a/src/hooks/post-commit.ts
+++ b/src/hooks/post-commit.ts
@@ -45,6 +45,7 @@ async function main() {
}
}
+ if (!data || typeof data !== "object") data = {};
if (isSdkChildContext(data)) return;
const cwd =
@@ -95,4 +96,4 @@ async function main() {
}
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/post-tool-failure.ts b/src/hooks/post-tool-failure.ts
index f0295b3e..3c8b25a1 100644
--- a/src/hooks/post-tool-failure.ts
+++ b/src/hooks/post-tool-failure.ts
@@ -29,6 +29,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
if (data.is_interrupt || data.isInterrupt) return;
@@ -63,4 +64,4 @@ async function main() {
setTimeout(() => process.exit(0), 500).unref();
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/post-tool-use.ts b/src/hooks/post-tool-use.ts
index c68a7731..a7e556de 100644
--- a/src/hooks/post-tool-use.ts
+++ b/src/hooks/post-tool-use.ts
@@ -29,6 +29,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = ((data.session_id || data.sessionId) as string) || "unknown";
@@ -114,4 +115,4 @@ function truncate(value: unknown, max: number): unknown {
return value;
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/pre-compact.ts b/src/hooks/pre-compact.ts
index 8bb2660c..339eec5d 100644
--- a/src/hooks/pre-compact.ts
+++ b/src/hooks/pre-compact.ts
@@ -29,6 +29,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = ((data.session_id || data.sessionId) as string) || "unknown";
@@ -66,4 +67,4 @@ async function main() {
}
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/pre-tool-use.ts b/src/hooks/pre-tool-use.ts
index 277d7799..eda68b45 100644
--- a/src/hooks/pre-tool-use.ts
+++ b/src/hooks/pre-tool-use.ts
@@ -48,6 +48,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const toolName =
@@ -123,4 +124,4 @@ async function main() {
}
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/prompt-submit.ts b/src/hooks/prompt-submit.ts
index 2da8ea6a..7f973b76 100644
--- a/src/hooks/prompt-submit.ts
+++ b/src/hooks/prompt-submit.ts
@@ -29,6 +29,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = ((data.session_id || data.sessionId) as string) || "unknown";
@@ -49,4 +50,4 @@ async function main() {
setTimeout(() => process.exit(0), 500).unref();
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/session-end.ts b/src/hooks/session-end.ts
index 6a9fc429..db149abd 100644
--- a/src/hooks/session-end.ts
+++ b/src/hooks/session-end.ts
@@ -28,6 +28,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = ((data.session_id || data.sessionId) as string) || "unknown";
@@ -66,4 +67,4 @@ async function main() {
setTimeout(() => process.exit(0), 1500).unref();
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/session-start.ts b/src/hooks/session-start.ts
index 573c092b..7e49a2df 100644
--- a/src/hooks/session-start.ts
+++ b/src/hooks/session-start.ts
@@ -47,6 +47,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId =
@@ -89,4 +90,4 @@ async function main() {
}
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/stop.ts b/src/hooks/stop.ts
index 4103796e..5eacd12e 100644
--- a/src/hooks/stop.ts
+++ b/src/hooks/stop.ts
@@ -31,6 +31,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) {
// Do not summarize from inside a Claude Agent SDK child session;
// would re-enter agent-sdk provider and loop (see sdk-guard.ts).
@@ -56,4 +57,4 @@ async function main() {
setTimeout(() => process.exit(0), 1500).unref();
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/subagent-start.ts b/src/hooks/subagent-start.ts
index 44c87c85..da1e6d34 100644
--- a/src/hooks/subagent-start.ts
+++ b/src/hooks/subagent-start.ts
@@ -37,6 +37,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = ((data.session_id || data.sessionId) as string) || "unknown";
@@ -62,4 +63,4 @@ async function main() {
setTimeout(() => process.exit(0), 500).unref();
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/subagent-stop.ts b/src/hooks/subagent-stop.ts
index 5a437c9f..be453ba9 100644
--- a/src/hooks/subagent-stop.ts
+++ b/src/hooks/subagent-stop.ts
@@ -29,6 +29,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = ((data.session_id || data.sessionId) as string) || "unknown";
@@ -59,4 +60,4 @@ async function main() {
setTimeout(() => process.exit(0), 500).unref();
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/hooks/task-completed.ts b/src/hooks/task-completed.ts
index dbdf815a..a72d594b 100644
--- a/src/hooks/task-completed.ts
+++ b/src/hooks/task-completed.ts
@@ -29,6 +29,7 @@ async function main() {
return;
}
+ if (!data || typeof data !== "object") return;
if (isSdkChildContext(data)) return;
const sessionId = (data.session_id as string) || "unknown";
@@ -57,4 +58,4 @@ async function main() {
setTimeout(() => process.exit(0), 500).unref();
}
-main();
+main().catch(() => process.exit(0));
diff --git a/src/triggers/api.ts b/src/triggers/api.ts
index 7b6c2bf2..99fb9908 100644
--- a/src/triggers/api.ts
+++ b/src/triggers/api.ts
@@ -324,7 +324,12 @@ export function registerApiTriggers(
sdk.registerFunction("api::context",
async (
- req: ApiRequest<{ sessionId: string; project: string; budget?: number }>,
+ req: ApiRequest<{
+ sessionId: string;
+ project: string;
+ budget?: number;
+ agentId?: string;
+ }>,
): Promise<Response> => {
const body = (req.body ?? {}) as Record<string, unknown>;
const sessionId = asNonEmptyString(body.sessionId);
@@ -342,11 +347,31 @@ export function registerApiTriggers(
body: { error: "budget must be a positive integer" },
};
}
- const payload: { sessionId: string; project: string; budget?: number } = {
+ // Propagate agentId so mem::context applies the same cross-agent
+ // isolation filter as mem::search. Honors body.agentId, ?agentId=,
+ // or the worker's AGENT_ID fallback under AGENTMEMORY_AGENT_SCOPE=isolated.
+ const queryAgentId =
+ typeof (req as { query_params?: Record<string, string> })
+ .query_params?.["agentId"] === "string"
+ ? (req as { query_params: Record<string, string> })
+ .query_params["agentId"]
+ : undefined;
+ const bodyAgentId =
+ typeof body.agentId === "string" && body.agentId.trim().length > 0
+ ? (body.agentId as string).trim()
+ : undefined;
+ const payload: {
+ sessionId: string;
+ project: string;
+ budget?: number;
+ agentId?: string;
+ } = {
sessionId,
project,
};
if (budget !== undefined) payload.budget = budget;
+ const agentId = bodyAgentId ?? queryAgentId;
+ if (agentId !== undefined) payload.agentId = agentId;
const result = await sdk.trigger({ function_id: "mem::context", payload });
return { status_code: 200, body: result };
},
@@ -595,9 +620,12 @@ export function registerApiTriggers(
};
await kv.set(KV.sessions, sessionId, session);
const contextResult = await sdk.trigger<
- { sessionId: string; project: string },
+ { sessionId: string; project: string; agentId?: string },
{ context: string }
- >({ function_id: "mem::context", payload: { sessionId, project } });
+ >({
+ function_id: "mem::context",
+ payload: { sessionId, project, ...(agentId ? { agentId } : {}) },
+ });
return {
status_code: 200,
body: { session, context: contextResult.context },
diff --git a/src/triggers/events.ts b/src/triggers/events.ts
index e38b58db..e75d615b 100644
--- a/src/triggers/events.ts
+++ b/src/triggers/events.ts
@@ -3,13 +3,23 @@ import type { CompressedObservation, HookPayload, Session } from "../types.js";
import { KV, STREAM } from "../state/schema.js";
import { StateKV } from "../state/kv.js";
import { isReflectEnabled } from "../functions/slots.js";
-import { isGraphExtractionEnabled } from "../config.js";
+import { getAgentId, isGraphExtractionEnabled } from "../config.js";
import { logger } from "../logger.js";
export function registerEventTriggers(sdk: ISdk, kv: StateKV): void {
sdk.registerFunction(
"event::session::started",
- async (data: { sessionId: string; project: string; cwd: string }) => {
+ async (data: {
+ sessionId: string;
+ project: string;
+ cwd: string;
+ agentId?: string;
+ }) => {
+ const requestAgentId =
+ typeof data.agentId === "string" && data.agentId.trim().length > 0
+ ? data.agentId.trim().slice(0, 128)
+ : undefined;
+ const agentId = requestAgentId ?? getAgentId();
const session: Session = {
id: data.sessionId,
project: data.project,
@@ -17,14 +27,19 @@ export function registerEventTriggers(sdk: ISdk, kv: StateKV): void {
startedAt: new Date().toISOString(),
status: "active",
observationCount: 0,
+ ...(agentId ? { agentId } : {}),
};
await kv.set(KV.sessions, data.sessionId, session);
const contextResult = await sdk.trigger<
- { sessionId: string; project: string },
+ { sessionId: string; project: string; agentId?: string },
{ context: string }
>({
function_id: "mem::context",
- payload: { sessionId: data.sessionId, project: data.project },
+ payload: {
+ sessionId: data.sessionId,
+ project: data.project,
+ ...(agentId ? { agentId } : {}),
+ },
});
return { session, context: contextResult.context };
},
diff --git a/src/types.ts b/src/types.ts
index 6797dfaf..113daeae 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -307,7 +307,7 @@ export interface ExportPagination {
}
export interface ExportData {
- version: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.7.7" | "0.7.9" | "0.8.0" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8" | "0.8.9" | "0.8.10" | "0.8.11" | "0.8.12" | "0.8.13" | "0.9.0" | "0.9.1" | "0.9.2" | "0.9.3" | "0.9.4" | "0.9.5" | "0.9.6" | "0.9.7" | "0.9.8" | "0.9.9" | "0.9.10" | "0.9.11" | "0.9.12" | "0.9.13" | "0.9.14" | "0.9.15" | "0.9.16" | "0.9.17" | "0.9.18" | "0.9.19" | "0.9.20" | "0.9.21" | "0.9.22" | "0.9.23" | "0.9.24" | "0.9.25" | "0.9.26" | "0.9.27";
+ version: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.7.7" | "0.7.9" | "0.8.0" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8" | "0.8.9" | "0.8.10" | "0.8.11" | "0.8.12" | "0.8.13" | "0.9.0" | "0.9.1" | "0.9.2" | "0.9.3" | "0.9.4" | "0.9.5" | "0.9.6" | "0.9.7" | "0.9.8" | "0.9.9" | "0.9.10" | "0.9.11" | "0.9.12" | "0.9.13" | "0.9.14" | "0.9.15" | "0.9.16" | "0.9.17" | "0.9.18" | "0.9.19" | "0.9.20" | "0.9.21" | "0.9.22" | "0.9.23" | "0.9.24" | "0.9.25" | "0.9.26" | "0.9.27" | "0.9.28";
exportedAt: string;
sessions: Session[];
observations: Record<string, CompressedObservation[]>;
diff --git a/src/version.ts b/src/version.ts
index 92784609..6d09f4f4 100644
--- a/src/version.ts
+++ b/src/version.ts
@@ -1 +1 @@
-export const VERSION = "0.9.27";
+export const VERSION = "0.9.28";
diff --git a/test/export-import.test.ts b/test/export-import.test.ts
index 39498626..39c17cab 100644
--- a/test/export-import.test.ts
+++ b/test/export-import.test.ts
@@ -119,7 +119,7 @@ describe("Export/Import Functions", () => {
it("export produces valid ExportData structure", async () => {
const result = (await sdk.trigger("mem::export", {})) as ExportData;
- expect(result.version).toBe("0.9.27");
+ expect(result.version).toBe("0.9.28");
expect(result.exportedAt).toBeDefined();
expect(result.sessions.length).toBe(1);
expect(result.sessions[0].id).toBe("ses_1");
diff --git a/website/lib/generated-meta.json b/website/lib/generated-meta.json
index 2c386052..06792f8e 100644
--- a/website/lib/generated-meta.json
+++ b/website/lib/generated-meta.json
@@ -1,8 +1,8 @@
{
- "version": "0.9.26",
+ "version": "0.9.28",
"mcpTools": 53,
"hooks": 12,
- "restEndpoints": 126,
- "testsPassing": 1394,
- "generatedAt": "2026-06-03T10:14:01.074Z"
+ "restEndpoints": 128,
+ "testsPassing": 1428,
+ "generatedAt": "2026-07-19T10:24:26.108Z"
}