Skip to content

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

fix(sessions): finalize idle sessions and keep summaries incremental (#1507)

Rohit Ghumaredf3d4a83b966
diff --git a/.env.example b/.env.example
index 6f112252..110a3291 100644
--- a/.env.example
+++ b/.env.example
@@ -229,6 +229,7 @@
# Hourly backstop that marks stale active sessions as abandoned.
# AGENTMEMORY_SESSION_SWEEP_ENABLED=false # Disable the hourly sweep
# AGENTMEMORY_SESSION_SWEEP_STALE_HOURS=24 # Inactivity hours before a session is abandoned
+# AGENTMEMORY_FINALIZE_IDLE_MS=120000 # Idle time after a per-turn Stop before the session is completed and summarized (0 = on every Stop)
# -----------------------------------------------------------------------------
# 10. Claude Code bridge (opt-in)
diff --git a/AGENTS.md b/AGENTS.md
index b7b5bb4d..1d41c57c 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -101,7 +101,7 @@ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import).
## Testing
-- Before every commit run, in order: `npm run build`, `npm run skills:gen`, `npm run docs:sync`, `npm run skills:check`, `npm test` (2,500+ tests). Commit anything the generators changed. CI runs the same build, skills check and tests.
+- Before every commit run, in order: `npm run build`, `npm run skills:gen`, `npm run docs:sync`, `npm run skills:check`, `npm test` (2,600+ tests). Commit anything the generators changed. CI runs the same build, skills check and tests.
- Before any npm publish: `npm run release:gate` must pass. It installs the packed tarballs into a clean home and runs capture, recovery, restart, export/import, MCP and status checks against the installed CLI (see CONTRIBUTING.md, Release process)
- Mock pattern: `vi.mock("iii-sdk")` with mock `sdk.trigger`, `kv.get/set/list`
- Test files go in `test/` with `.test.ts` extension
@@ -113,5 +113,5 @@ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import).
- 138 REST endpoints
- 6 MCP resources, 3 MCP prompts
- 12 hooks, 17 skills
-- 311+ iii functions
-- 2,500+ tests
+- 312+ iii functions
+- 2,600+ tests
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 69983166..aa031b24 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## [Unreleased]
+### Fixed
+
+- **Session summaries cover the whole session again** (#745). 0.9.30 completed a session on the first per-turn Stop and ignored every later end, so summaries and graph extraction stopped at turn 1. `mem::observe` now reopens a completed session when new observations arrive, the Stop hook sends `final: false` so the session stays open, and an idle finalizer completes it once nothing has happened for `AGENTMEMORY_FINALIZE_IDLE_MS` (default 2 minutes). SessionEnd, the CLI and the OpenCode plugin send `final: true` and complete at once; a request without the flag behaves as before. The sweep summarizes a session before marking it abandoned (#737).
+- **Summaries are incremental.** `mem::summarize` keeps a watermark (`coveredThrough`) and summarizes only the observations captured since the last run, merging them into the stored summary with one reduce call. A session end with nothing new costs no LLM call, and the reflect, graph and skill fan-out is skipped for it.
+
### Changed
- `@agentmemory/mcp` pins the exact matching `@agentmemory/agentmemory` release instead of a `~` range, so an installed shim never resolves a newer runtime than the one it was published with.
diff --git a/README.md b/README.md
index 800aa737..0b664aa0 100644
--- a/README.md
+++ b/README.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tools.svg"><img src="assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| Custom plugin systems | `iii worker add <name>` |
-**219 source files · ~52,000 LOC · 2,500+ tests · 311 functions · 60 KV scopes**, all on three primitives. No `agentmemory plugin install`. The plugin system is iii itself.
+**220 source files · ~52,000 LOC · 2,600+ tests · 312 functions · 60 KV scopes**, all on three primitives. No `agentmemory plugin install`. The plugin system is iii itself.
---
@@ -1761,6 +1761,9 @@ Create `~/.agentmemory/.env`:
# the threshold as abandoned. Deletes nothing;
# new activity makes the session active again.
# AGENTMEMORY_SESSION_SWEEP_STALE_HOURS=24
+# AGENTMEMORY_FINALIZE_IDLE_MS=120000 # Per-turn Stop hooks leave the session open; it
+ # is completed and summarized once it has been idle
+ # this long. 0 completes it on every Stop.
# Capture filters (hooks)
# AGENTMEMORY_CAPTURE_ALLOW= # Comma or space list of tool names or globs;
@@ -1812,7 +1815,7 @@ curl -H "Authorization: Bearer $(cat ~/.agentmemory/secret)" http://localhost:31
| `GET` | `/agentmemory/status` | What is wrong and how to fix it (HTML for browsers, JSON otherwise) |
| `GET` | `/agentmemory/viewer/snapshot` | Everything the viewer shows, in one response |
| `POST` | `/agentmemory/session/start` | Start session + get context |
-| `POST` | `/agentmemory/session/end` | End session |
+| `POST` | `/agentmemory/session/end` | End session; `final: false` (per-turn hooks) defers completion until the session is idle |
| `POST` | `/agentmemory/observe` | Capture observation (see capture delivery below) |
| `GET` | `/agentmemory/capture` | Capture inbox, dead letters and offline spool |
| `POST` | `/agentmemory/capture/retry` | Retry dead-letter captures |
@@ -1870,7 +1873,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.ar-SA.md b/READMEs/README.ar-SA.md
index dc8c8ba4..6c8e718e 100644
--- a/READMEs/README.ar-SA.md
+++ b/READMEs/README.ar-SA.md
@@ -73,7 +73,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1439,7 +1439,7 @@ fi
| Prometheus / Grafana | OTEL في iii + مراقب الحالة الصحية |
| أنظمة إضافات مخصصة | `iii worker add <name>` |
-**219 ملف مصدري · ~52,000 سطر برمجي · 2,500+ اختبار · 311 دالة · 60 نطاق KV**، كل ذلك على ثلاث بنى أساسية. لا يوجد أمر `agentmemory plugin install`. نظام الإضافات هو iii نفسه.
+**220 ملف مصدري · ~52,000 سطر برمجي · 2,600+ اختبار · 312 دالة · 60 نطاق KV**، كل ذلك على ثلاث بنى أساسية. لا يوجد أمر `agentmemory plugin install`. نظام الإضافات هو iii نفسه.
---
@@ -1863,7 +1863,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.bn-BD.md b/READMEs/README.bn-BD.md
index 37e5e70e..eb0a3f27 100644
--- a/READMEs/README.bn-BD.md
+++ b/READMEs/README.bn-BD.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 MCP টুল" 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 অটো হুক" 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 এক্সটার্নাল ডিবি" 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="2,500+ টেস্ট পাস" 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="2,600+ টেস্ট পাস" height="38" /></picture>
</p>
<p align="center">
@@ -1437,7 +1437,7 @@ fi
| Prometheus / Grafana | iii OTEL + হেলথ মনিটর |
| কাস্টম প্লাগইন সিস্টেম | `iii worker add <name>` |
-**219 সোর্স ফাইল · ~52,000 LOC · 2,500+ টেস্ট · 311 ফাংশন · 60 KV স্কোপ**, সবকিছু তিনটি প্রিমিটিভের উপর। কোনো `agentmemory plugin install` নেই। প্লাগইন সিস্টেমটাই iii নিজে।
+**220 সোর্স ফাইল · ~52,000 LOC · 2,600+ টেস্ট · 312 ফাংশন · 60 KV স্কোপ**, সবকিছু তিনটি প্রিমিটিভের উপর। কোনো `agentmemory plugin install` নেই। প্লাগইন সিস্টেমটাই iii নিজে।
---
@@ -1861,7 +1861,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.cs-CZ.md b/READMEs/README.cs-CZ.md
index aaa98d2e..14e56293 100644
--- a/READMEs/README.cs-CZ.md
+++ b/READMEs/README.cs-CZ.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 MCP nástrojů" 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 automatických 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 externích databází" 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="2,500+ testů úspěšně proběhlo" 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="2,600+ testů úspěšně proběhlo" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| Vlastní systémy pluginů | `iii worker add <name>` |
-**219 zdrojových souborů · ~52,000 řádků kódu · 2,500+ testů · 311 funkcí · 60 KV scopes**, vše na třech primitivech. Žádné `agentmemory plugin install`. Systém pluginů je samo iii.
+**220 zdrojových souborů · ~52,000 řádků kódu · 2,600+ testů · 312 funkcí · 60 KV scopes**, vše na třech primitivech. Žádné `agentmemory plugin install`. Systém pluginů je samo iii.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.da-DK.md b/READMEs/README.da-DK.md
index 84c5ab8f..7b442c18 100644
--- a/READMEs/README.da-DK.md
+++ b/READMEs/README.da-DK.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 MCP-værktøjer" 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 automatiske 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 eksterne databaser" 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="2,500+ beståede tests" 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="2,600+ beståede tests" height="38" /></picture>
</p>
<p align="center">
@@ -1436,7 +1436,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| Custom plugin-systemer | `iii worker add <name>` |
-**219 kildefiler · ~52,000 LOC · 2,500+ tests · 311 funktioner · 60 KV-scopes**, alt på tre primitiver. Intet `agentmemory plugin install`. Plugin-systemet er iii selv.
+**220 kildefiler · ~52,000 LOC · 2,600+ tests · 312 funktioner · 60 KV-scopes**, alt på tre primitiver. Intet `agentmemory plugin install`. Plugin-systemet er iii selv.
---
@@ -1860,7 +1860,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ 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 2620da4d..32906825 100644
--- a/READMEs/README.de-DE.md
+++ b/READMEs/README.de-DE.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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 externe 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="2,500+ bestandene Tests" 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="2,600+ bestandene Tests" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + Health-Monitor |
| Eigene Plugin-Systeme | `iii worker add <name>` |
-**219 Quelldateien · ~52,000 LOC · 2,500+ Tests · 311 Funktionen · 60 KV-Scopes**, alles auf drei Primitiven. Kein `agentmemory plugin install`. Das Plugin-System ist iii selbst.
+**220 Quelldateien · ~52,000 LOC · 2,600+ Tests · 312 Funktionen · 60 KV-Scopes**, alles auf drei Primitiven. Kein `agentmemory plugin install`. Das Plugin-System ist iii selbst.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.el-GR.md b/READMEs/README.el-GR.md
index a7048492..a7ae202c 100644
--- a/READMEs/README.el-GR.md
+++ b/READMEs/README.el-GR.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 εργαλεία MCP" 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 αυτόματα 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 εξωτερικές βάσεις δεδομένων" 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="2,500+ επιτυχημένες δοκιμές" 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="2,600+ επιτυχημένες δοκιμές" height="38" /></picture>
</p>
<p align="center">
@@ -1438,7 +1438,7 @@ fi
| Prometheus / Grafana | iii OTEL + monitor υγείας |
| Προσαρμοσμένα συστήματα plugin | `iii worker add <name>` |
-**219 αρχεία πηγαίου κώδικα · ~52,000 LOC · 2,500+ δοκιμές · 311 functions · 60 KV scopes**, όλα πάνω σε τρία primitives. Δεν υπάρχει `agentmemory plugin install`. Το σύστημα plugin είναι το ίδιο το iii.
+**220 αρχεία πηγαίου κώδικα · ~52,000 LOC · 2,600+ δοκιμές · 312 functions · 60 KV scopes**, όλα πάνω σε τρία primitives. Δεν υπάρχει `agentmemory plugin install`. Το σύστημα plugin είναι το ίδιο το iii.
---
@@ -1862,7 +1862,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.es-ES.md b/READMEs/README.es-ES.md
index c680fec4..00e1aa7a 100644
--- a/READMEs/README.es-ES.md
+++ b/READMEs/README.es-ES.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 tools MCP" 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 hooks automáticos" 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 bases de datos externas" 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="2,500+ tests superados" 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="2,600+ tests superados" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + monitor de salud |
| Sistemas de plugins propios | `iii worker add <name>` |
-**219 ficheros de código · ~52,000 LOC · 2,500+ tests · 311 funciones · 60 scopes KV**, todo sobre tres primitivos. No hay `agentmemory plugin install`. El sistema de plugins es iii mismo.
+**220 ficheros de código · ~52,000 LOC · 2,600+ tests · 312 funciones · 60 scopes KV**, todo sobre tres primitivos. No hay `agentmemory plugin install`. El sistema de plugins es iii mismo.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.fi-FI.md b/READMEs/README.fi-FI.md
index c56cf556..9de4a8bd 100644
--- a/READMEs/README.fi-FI.md
+++ b/READMEs/README.fi-FI.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 MCP-työkalua" 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 automaattista hookia" 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 ulkoista tietokantaa" 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="2,500+ testiä läpäisty" 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="2,600+ testiä läpäisty" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + terveysmonitori |
| Mukautetut plugin-järjestelmät | `iii worker add <name>` |
-**219 lähdetiedostoa · ~52,000 LOC · 2,500+ testiä · 311 funktiota · 60 KV-scopea**, kaikki kolmen primitiivin päällä. Ei `agentmemory plugin install` -komentoa. Plugin-järjestelmä on iii itse.
+**220 lähdetiedostoa · ~52,000 LOC · 2,600+ testiä · 312 funktiota · 60 KV-scopea**, kaikki kolmen primitiivin päällä. Ei `agentmemory plugin install` -komentoa. Plugin-järjestelmä on iii itse.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.fr-FR.md b/READMEs/README.fr-FR.md
index e5f067ca..c56106d0 100644
--- a/READMEs/README.fr-FR.md
+++ b/READMEs/README.fr-FR.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1448,7 +1448,7 @@ fi
| Prometheus / Grafana | iii OTEL + moniteur de santé |
| Systèmes de plugins custom | `iii worker add <name>` |
-**219 fichiers sources · ~52,000 LOC · 2,500+ tests · 311 fonctions · 60 scopes KV**, tout sur trois primitives. Pas de `agentmemory plugin install`. Le système de plugins, c'est iii lui-même.
+**220 fichiers sources · ~52,000 LOC · 2,600+ tests · 312 fonctions · 60 scopes KV**, tout sur trois primitives. Pas de `agentmemory plugin install`. Le système de plugins, c'est iii lui-même.
---
@@ -1872,7 +1872,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.he-IL.md b/READMEs/README.he-IL.md
index 6c969c84..e63951b5 100644
--- a/READMEs/README.he-IL.md
+++ b/READMEs/README.he-IL.md
@@ -73,7 +73,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 כלי MCP" 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 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 מסדי נתונים חיצוניים" 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="2,500+ בדיקות עוברות" 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="2,600+ בדיקות עוברות" height="38" /></picture>
</p>
<p align="center">
@@ -1439,7 +1439,7 @@ fi
| Prometheus / Grafana | iii OTEL + מוניטור health |
| מערכות plugin מותאמות אישית | `iii worker add <name>` |
-**219 קבצי מקור · ~52,000 LOC · 2,500+ בדיקות · 311 פונקציות · 60 תחומי KV**, הכול על שלושה primitives. אין `agentmemory plugin install`. מערכת ה-plugin היא iii עצמו.
+**220 קבצי מקור · ~52,000 LOC · 2,600+ בדיקות · 312 פונקציות · 60 תחומי KV**, הכול על שלושה primitives. אין `agentmemory plugin install`. מערכת ה-plugin היא iii עצמו.
---
@@ -1863,7 +1863,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.hi-IN.md b/READMEs/README.hi-IN.md
index fa5427fe..ea4b48e9 100644
--- a/READMEs/README.hi-IN.md
+++ b/READMEs/README.hi-IN.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1449,7 +1449,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| Custom plugin systems | `iii worker add <name>` |
-**219 source files · ~52,000 LOC · 2,500+ tests · 311 functions · 60 KV scopes**, सब कुछ तीन primitives पर। कोई `agentmemory plugin install` नहीं। Plugin system iii स्वयं है।
+**220 source files · ~52,000 LOC · 2,600+ tests · 312 functions · 60 KV scopes**, सब कुछ तीन primitives पर। कोई `agentmemory plugin install` नहीं। Plugin system iii स्वयं है।
---
@@ -1873,7 +1873,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.hu-HU.md b/READMEs/README.hu-HU.md
index 7ac4d032..95bd5e77 100644
--- a/READMEs/README.hu-HU.md
+++ b/READMEs/README.hu-HU.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 MCP eszköz" 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 automatikus hook" 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 külső adatbázis" 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="2,500+ sikeres teszt" 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="2,600+ sikeres teszt" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ A `/agentmemory/export` emellett elfogadja a `?maxSessions=`-t és a `?offset=`-
| Prometheus / Grafana | iii OTEL + egészségfigyelő |
| Egyéni plugin-rendszerek | `iii worker add <name>` |
-**219 forrásfájl · ~52,000 LOC · 2,500+ teszt · 311 funkció · 60 KV-hatókör**, mindez három primitíven. Nincs `agentmemory plugin install`. A plugin-rendszer maga az iii.
+**220 forrásfájl · ~52,000 LOC · 2,600+ teszt · 312 funkció · 60 KV-hatókör**, mindez három primitíven. Nincs `agentmemory plugin install`. A plugin-rendszer maga az iii.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.id-ID.md b/READMEs/README.id-ID.md
index 1e82a39e..0d7c985d 100644
--- a/READMEs/README.id-ID.md
+++ b/READMEs/README.id-ID.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 tool MCP" 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 hook otomatis" 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 DB eksternal" 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="2,500+ pengujian lolos" 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="2,600+ pengujian lolos" height="38" /></picture>
</p>
<p align="center">
@@ -1447,7 +1447,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| Sistem plugin custom | `iii worker add <name>` |
-**219 file sumber · ~52,000 LOC · 2,500+ pengujian · 311 fungsi · 60 scope KV**, semua di atas tiga primitif. Tidak ada `agentmemory plugin install`. Sistem plugin-nya adalah iii itu sendiri.
+**220 file sumber · ~52,000 LOC · 2,600+ pengujian · 312 fungsi · 60 scope KV**, semua di atas tiga primitif. Tidak ada `agentmemory plugin install`. Sistem plugin-nya adalah iii itu sendiri.
---
@@ -1871,7 +1871,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.it-IT.md b/READMEs/README.it-IT.md
index 3d61a05f..fd0a2d12 100644
--- a/READMEs/README.it-IT.md
+++ b/READMEs/README.it-IT.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + monitor di salute |
| Sistemi di plugin personalizzati | `iii worker add <name>` |
-**219 file sorgente · ~52,000 righe di codice · 2,500+ test · 311 funzioni · 60 scope KV**, tutto su tre primitive. Nessun `agentmemory plugin install`. Il sistema di plugin è iii stesso.
+**220 file sorgente · ~52,000 righe di codice · 2,600+ test · 312 funzioni · 60 scope KV**, tutto su tre primitive. Nessun `agentmemory plugin install`. Il sistema di plugin è iii stesso.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.ja-JP.md b/READMEs/README.ja-JP.md
index 502b6d4c..7f080a19 100644
--- a/READMEs/README.ja-JP.md
+++ b/READMEs/README.ja-JP.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 MCP ツール" 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 自動 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="外部 DB 0 個" 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="2,500+ 件のテストが成功" 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="2,600+ 件のテストが成功" height="38" /></picture>
</p>
<p align="center">
@@ -1445,7 +1445,7 @@ fi
| Prometheus / Grafana | iii OTEL + ヘルスモニタ |
| カスタムプラグインシステム | `iii worker add <name>` |
-**219 ソースファイル · ~52,000 LOC · 2,500+ テスト · 311 functions · 60 KV スコープ** — すべて 3 つのプリミティブの上に。`agentmemory plugin install` はありません。プラグインシステムは iii そのものです。
+**220 ソースファイル · ~52,000 LOC · 2,600+ テスト · 312 functions · 60 KV スコープ** — すべて 3 つのプリミティブの上に。`agentmemory plugin install` はありません。プラグインシステムは iii そのものです。
---
@@ -1869,7 +1869,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.ko-KR.md b/READMEs/README.ko-KR.md
index e929c0b3..94bcd342 100644
--- a/READMEs/README.ko-KR.md
+++ b/READMEs/README.ko-KR.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + health 모니터 |
| 커스텀 플러그인 시스템 | `iii worker add <name>` |
-**소스 파일 219개 · LOC ~52,000줄 · 테스트 2,500+개 · 함수 311개 · KV 스코프 60개**, 모두 세 가지 프리미티브 위에서 동작합니다. `agentmemory plugin install` 같은 것은 없습니다. 플러그인 시스템은 곧 iii 자체입니다.
+**소스 파일 220개 · LOC ~52,000줄 · 테스트 2,600+개 · 함수 312개 · KV 스코프 60개**, 모두 세 가지 프리미티브 위에서 동작합니다. `agentmemory plugin install` 같은 것은 없습니다. 플러그인 시스템은 곧 iii 자체입니다.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.nb-NO.md b/READMEs/README.nb-NO.md
index 7715107a..7875e502 100644
--- a/READMEs/README.nb-NO.md
+++ b/READMEs/README.nb-NO.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1447,7 +1447,7 @@ fi
| Prometheus / Grafana | iii OTEL + helseovervåker |
| Egendefinerte plugin-systemer | `iii worker add <name>` |
-**219 kildefiler · ~52,000 LOC · 2,500+ tester · 311 funksjoner · 60 KV-scopes**, alt på tre primitiver. Ingen `agentmemory plugin install`. Plugin-systemet er iii selv.
+**220 kildefiler · ~52,000 LOC · 2,600+ tester · 312 funksjoner · 60 KV-scopes**, alt på tre primitiver. Ingen `agentmemory plugin install`. Plugin-systemet er iii selv.
---
@@ -1871,7 +1871,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.nl-NL.md b/READMEs/README.nl-NL.md
index 4888039d..5b2fa0b2 100644
--- a/READMEs/README.nl-NL.md
+++ b/READMEs/README.nl-NL.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| Custom plugin-systemen | `iii worker add <name>` |
-**219 bronbestanden · ~52,000 LOC · 2,500+ tests · 311 functies · 60 KV-scopes**, allemaal op drie primitieven. Geen `agentmemory plugin install`. Het pluginsysteem is iii zelf.
+**220 bronbestanden · ~52,000 LOC · 2,600+ tests · 312 functies · 60 KV-scopes**, allemaal op drie primitieven. Geen `agentmemory plugin install`. Het pluginsysteem is iii zelf.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.pl-PL.md b/READMEs/README.pl-PL.md
index 97c41857..d9f046d5 100644
--- a/READMEs/README.pl-PL.md
+++ b/READMEs/README.pl-PL.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 narzędzia MCP" 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 automatycznych hooków" 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 zewnętrznych baz danych" 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="2,500+ zaliczonych testów" 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="2,600+ zaliczonych testów" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + monitor stanu |
| Niestandardowe systemy pluginów | `iii worker add <name>` |
-**219 plików źródłowych · ~52,000 LOC · 2,500+ testów · 311 funkcji · 60 zakresów KV**, wszystko na trzech prymitywach. Nie ma `agentmemory plugin install`. Systemem pluginów jest sam iii.
+**220 plików źródłowych · ~52,000 LOC · 2,600+ testów · 312 funkcji · 60 zakresów KV**, wszystko na trzech prymitywach. Nie ma `agentmemory plugin install`. Systemem pluginów jest sam iii.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.pt-BR.md b/READMEs/README.pt-BR.md
index d9eeb248..a21e6bd7 100644
--- a/READMEs/README.pt-BR.md
+++ b/READMEs/README.pt-BR.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1447,7 +1447,7 @@ fi
| Prometheus / Grafana | iii OTEL + monitor de saúde |
| Sistemas de plugin customizados | `iii worker add <name>` |
-**219 arquivos de código · ~52,000 LOC · 2,500+ testes · 311 funções · 60 escopos KV**, tudo em cima de três primitivos. Sem `agentmemory plugin install`. O sistema de plugins é o próprio iii.
+**220 arquivos de código · ~52,000 LOC · 2,600+ testes · 312 funções · 60 escopos KV**, tudo em cima de três primitivos. Sem `agentmemory plugin install`. O sistema de plugins é o próprio iii.
---
@@ -1871,7 +1871,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.pt-PT.md b/READMEs/README.pt-PT.md
index a1a5474c..bb0a0c0b 100644
--- a/READMEs/README.pt-PT.md
+++ b/READMEs/README.pt-PT.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 ferramentas MCP" 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 hooks automáticos" 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 bases de dados externas" 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="2,500+ testes aprovados" 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="2,600+ testes aprovados" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ O `/agentmemory/export` também aceita `?maxSessions=` e `?offset=` para dividir
| Prometheus / Grafana | iii OTEL + monitor de saúde |
| Sistemas de plugins personalizados | `iii worker add <name>` |
-**219 ficheiros de código-fonte · ~52,000 LOC · 2,500+ testes · 311 funções · 60 âmbitos de KV**, tudo sobre três primitivos. Sem `agentmemory plugin install`. O sistema de plugins é o próprio iii.
+**220 ficheiros de código-fonte · ~52,000 LOC · 2,600+ testes · 312 funções · 60 âmbitos de KV**, tudo sobre três primitivos. Sem `agentmemory plugin install`. O sistema de plugins é o próprio iii.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.ro-RO.md b/READMEs/README.ro-RO.md
index f6bdb61b..ac4349c1 100644
--- a/READMEs/README.ro-RO.md
+++ b/READMEs/README.ro-RO.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 de instrumente MCP" 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 hook-uri automate" 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 baze de date externe" 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="2,500+ teste trecute" 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="2,600+ teste trecute" height="38" /></picture>
</p>
<p align="center">
@@ -1430,7 +1430,7 @@ fi
| Prometheus / Grafana | iii OTEL + monitor de sănătate |
| Sisteme de plugin-uri personalizate | `iii worker add <name>` |
-**219 fișiere sursă · ~52,000 LOC · 2,500+ teste · 311 funcții · 60 domenii KV**, toate pe trei primitive. Niciun `agentmemory plugin install`. Sistemul de plugin-uri este chiar iii.
+**220 fișiere sursă · ~52,000 LOC · 2,600+ teste · 312 funcții · 60 domenii KV**, toate pe trei primitive. Niciun `agentmemory plugin install`. Sistemul de plugin-uri este chiar iii.
---
@@ -1854,7 +1854,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.ru-RU.md b/READMEs/README.ru-RU.md
index f74bdbdc..3546d60c 100644
--- a/READMEs/README.ru-RU.md
+++ b/READMEs/README.ru-RU.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ fi
| Prometheus / Grafana | iii OTEL + монитор состояния |
| Самописные плагинные системы | `iii worker add <name>` |
-**219 исходных файлов · ~52,000 LOC · 2,500+ тестов · 311 функция · 60 KV-scope'ов**, всё на трёх примитивах. Никакого `agentmemory plugin install`. Плагинная система — это сам iii.
+**220 исходных файлов · ~52,000 LOC · 2,600+ тестов · 312 функция · 60 KV-scope'ов**, всё на трёх примитивах. Никакого `agentmemory plugin install`. Плагинная система — это сам iii.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.sv-SE.md b/READMEs/README.sv-SE.md
index 97c427db..8b56965d 100644
--- a/READMEs/README.sv-SE.md
+++ b/READMEs/README.sv-SE.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 MCP-verktyg" 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 automatiska 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 externa databaser" 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="2,500+ godkända tester" 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="2,600+ godkända tester" height="38" /></picture>
</p>
<p align="center">
@@ -1437,7 +1437,7 @@ fi
| Prometheus / Grafana | iii OTEL + hälsoövervakare |
| Anpassade pluginsystem | `iii worker add <name>` |
-**219 källkodsfiler · ~52,000 LOC · 2,500+ tester · 311 funktioner · 60 KV-scopes**, allt på tre primitiv. Inget `agentmemory plugin install`. Pluginsystemet är iii självt.
+**220 källkodsfiler · ~52,000 LOC · 2,600+ tester · 312 funktioner · 60 KV-scopes**, allt på tre primitiv. Inget `agentmemory plugin install`. Pluginsystemet är iii självt.
---
@@ -1861,7 +1861,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.th-TH.md b/READMEs/README.th-TH.md
index 5de7ed09..a453c441 100644
--- a/READMEs/README.th-TH.md
+++ b/READMEs/README.th-TH.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 เครื่องมือ MCP" 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 hook อัตโนมัติ" 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="ไม่ต้องพึ่ง external DB เลย" 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="ผ่านการทดสอบ 2,500+ รายการ" 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="ผ่านการทดสอบ 2,600+ รายการ" height="38" /></picture>
</p>
<p align="center">
@@ -1444,7 +1444,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| Custom plugin systems | `iii worker add <name>` |
-**219 source file · ~52,000 LOC · 2,500+ การทดสอบ · 311 function · 60 KV scope** ทั้งหมดอยู่บน primitive สามตัว ไม่มี `agentmemory plugin install` ระบบ plugin ก็คือ iii เองนั่นแหละ
+**220 source file · ~52,000 LOC · 2,600+ การทดสอบ · 312 function · 60 KV scope** ทั้งหมดอยู่บน primitive สามตัว ไม่มี `agentmemory plugin install` ระบบ plugin ก็คือ iii เองนั่นแหละ
---
@@ -1868,7 +1868,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.tl-PH.md b/READMEs/README.tl-PH.md
index 062f9784..b99e89d1 100644
--- a/READMEs/README.tl-PH.md
+++ b/READMEs/README.tl-PH.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 MCP tool" 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 awtomatikong hook" 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 panlabas na DB" 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="2,500+ pumapasang test" 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="2,600+ pumapasang test" height="38" /></picture>
</p>
<p align="center">
@@ -1446,7 +1446,7 @@ Tinatanggap din ng `/agentmemory/export` ang `?maxSessions=` at `?offset=` para
| Prometheus / Grafana | iii OTEL + health monitor |
| Custom na plugin system | `iii worker add <name>` |
-**219 na source file · ~52,000 LOC · 2,500+ na test · 311 na function · 60 na KV scope**, lahat sa tatlong primitive. Walang `agentmemory plugin install`. Ang plugin system mismo ay ang iii.
+**220 na source file · ~52,000 LOC · 2,600+ na test · 312 na function · 60 na KV scope**, lahat sa tatlong primitive. Walang `agentmemory plugin install`. Ang plugin system mismo ay ang iii.
---
@@ -1870,7 +1870,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.tr-TR.md b/READMEs/README.tr-TR.md
index b55fb3cb..04f6e194 100644
--- a/READMEs/README.tr-TR.md
+++ b/READMEs/README.tr-TR.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1437,7 +1437,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| Custom eklenti sistemleri | `iii worker add <name>` |
-**219 kaynak dosya · ~52,000 LOC · 2,500+ test · 311 fonksiyon · 60 KV scope**, hepsi üç primitif üzerinde. `agentmemory plugin install` yok. Eklenti sistemi, iii'nin kendisidir.
+**220 kaynak dosya · ~52,000 LOC · 2,600+ test · 312 fonksiyon · 60 KV scope**, hepsi üç primitif üzerinde. `agentmemory plugin install` yok. Eklenti sistemi, iii'nin kendisidir.
---
@@ -1861,7 +1861,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.uk-UA.md b/READMEs/README.uk-UA.md
index a6f8e22b..73bee280 100644
--- a/READMEs/README.uk-UA.md
+++ b/READMEs/README.uk-UA.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 інструменти MCP" 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 автоматичних хуків" 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 зовнішніх БД" 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="2,500+ тестів пройдено" 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="2,600+ тестів пройдено" height="38" /></picture>
</p>
<p align="center">
@@ -1447,7 +1447,7 @@ fi
| Prometheus / Grafana | iii OTEL + монітор стану здоров'я |
| Власні системи плагінів | `iii worker add <name>` |
-**219 вихідних файлів · ~52,000 LOC · 2,500+ тестів · 311 функцій · 60 KV-скоупів**, усе на трьох примітивах. Жодного `agentmemory plugin install`. Система плагінів — це сам iii.
+**220 вихідних файлів · ~52,000 LOC · 2,600+ тестів · 312 функцій · 60 KV-скоупів**, усе на трьох примітивах. Жодного `agentmemory plugin install`. Система плагінів — це сам iii.
---
@@ -1871,7 +1871,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.ur-PK.md b/READMEs/README.ur-PK.md
index 46955c26..5a6f6599 100644
--- a/READMEs/README.ur-PK.md
+++ b/READMEs/README.ur-PK.md
@@ -73,7 +73,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 MCP ٹولز" 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 خودکار ہکس" 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 خارجی ڈیٹابیسز" 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="2,500+ ٹیسٹس پاس ہو رہے ہیں" 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="2,600+ ٹیسٹس پاس ہو رہے ہیں" height="38" /></picture>
</p>
<p align="center">
@@ -1432,7 +1432,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| کسٹم plugin سسٹمز | `iii worker add <name>` |
-**219 سورس فائلز · ~52,000 لائنز کوڈ · 2,500+ ٹیسٹس · 311 فنکشنز · 60 KV اسکوپس**، سب تین primitives پر۔ کوئی `agentmemory plugin install` نہیں۔ plugin سسٹم خود iii ہی ہے۔
+**220 سورس فائلز · ~52,000 لائنز کوڈ · 2,600+ ٹیسٹس · 312 فنکشنز · 60 KV اسکوپس**، سب تین primitives پر۔ کوئی `agentmemory plugin install` نہیں۔ plugin سسٹم خود iii ہی ہے۔
---
@@ -1854,7 +1854,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.vi-VN.md b/READMEs/README.vi-VN.md
index 8704a429..7cb76258 100644
--- a/READMEs/README.vi-VN.md
+++ b/READMEs/README.vi-VN.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 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="2,500+ 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="2,600+ tests passing" height="38" /></picture>
</p>
<p align="center">
@@ -1437,7 +1437,7 @@ fi
| Prometheus / Grafana | iii OTEL + health monitor |
| Hệ thống plugin tùy chỉnh | `iii worker add <name>` |
-**219 file source · ~52,000 LOC · 2,500+ test · 311 function · 60 KV scope**, tất cả trên ba primitive. Không có `agentmemory plugin install`. Hệ thống plugin chính là iii.
+**220 file source · ~52,000 LOC · 2,600+ test · 312 function · 60 KV scope**, tất cả trên ba primitive. Không có `agentmemory plugin install`. Hệ thống plugin chính là iii.
---
@@ -1861,7 +1861,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.zh-CN.md b/READMEs/README.zh-CN.md
index 3ef47ba6..3cd9d255 100644
--- a/READMEs/README.zh-CN.md
+++ b/READMEs/README.zh-CN.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 个 MCP 工具" 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 个自动 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 个外部数据库" 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="2,500+ 项测试通过" 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="2,600+ 项测试通过" height="38" /></picture>
</p>
<p align="center">
@@ -1444,7 +1444,7 @@ fi
| Prometheus / Grafana | iii OTEL + 健康监控 |
| Custom plugin systems | `iii worker add <name>` |
-**219 个源文件 · ~52,000 行代码 · 2,500+ 个测试 · 311 个函数 · 60 个 KV 作用域**,全部基于三种原语。没有 `agentmemory plugin install`。插件系统就是 iii 本身。
+**220 个源文件 · ~52,000 行代码 · 2,600+ 个测试 · 312 个函数 · 60 个 KV 作用域**,全部基于三种原语。没有 `agentmemory plugin install`。插件系统就是 iii 本身。
---
@@ -1868,7 +1868,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/READMEs/README.zh-TW.md b/READMEs/README.zh-TW.md
index 3c9250fb..57a1c78d 100644
--- a/READMEs/README.zh-TW.md
+++ b/READMEs/README.zh-TW.md
@@ -71,7 +71,7 @@
<picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="54 個 MCP 工具" 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 個自動 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 個外部資料庫" 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="2,500+ 測試通過" 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="2,600+ 測試通過" height="38" /></picture>
</p>
<p align="center">
@@ -1430,7 +1430,7 @@ fi
| Prometheus / Grafana | iii OTEL + 健康監控 |
| 自訂外掛系統 | `iii worker add <name>` |
-**219 個原始檔 · ~52,000 行程式碼 · 2,500+ 測試 · 311 個函式 · 60 個 KV 範圍**,全部基於三種原語。沒有 `agentmemory plugin install`。外掛系統就是 iii 本身。
+**220 個原始檔 · ~52,000 行程式碼 · 2,600+ 測試 · 312 個函式 · 60 個 KV 範圍**,全部基於三種原語。沒有 `agentmemory plugin install`。外掛系統就是 iii 本身。
---
@@ -1854,7 +1854,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Content-Type: a
```bash
npm run dev # Hot reload
npm run build # Production build
-npm test # 2,500+ tests
+npm test # 2,600+ tests
npm run test:integration # API tests (requires running services)
```
diff --git a/assets/tags/light/stat-tests.svg b/assets/tags/light/stat-tests.svg
index 1bb69e34..4dfe9de3 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: 2500+">
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 48" fill="none" role="img" aria-label="TESTS PASSING: 2600+">
<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">2500+</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">2600+</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 44c9fc27..b704fbe7 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: 2500+">
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 48" fill="none" role="img" aria-label="TESTS PASSING: 2600+">
<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">2500+</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">2600+</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/plugin/opencode/agentmemory-capture.ts b/plugin/opencode/agentmemory-capture.ts
index 870f7662..a5ab188c 100644
--- a/plugin/opencode/agentmemory-capture.ts
+++ b/plugin/opencode/agentmemory-capture.ts
@@ -380,7 +380,7 @@ const v1Hooks: Plugin = async (ctx) => {
if (DEBUG) console.error("[agentmemory] session.deleted with no session ID");
return;
}
- await post("/session/end", { sessionId: sid });
+ await post("/session/end", { sessionId: sid, final: true });
post("/crystals/auto", { olderThanDays: 7 }, 30000);
post("/consolidate-pipeline", { tier: "all", force: true }, 30000);
if (sid === activeSessionId) activeSessionId = null;
@@ -1260,7 +1260,7 @@ async function v2Setup(ctx: any) {
case "session.deleted": {
const sid = (data.sessionID as string) || activeSessionId;
if (!sid) return;
- await post("/session/end", { sessionId: sid });
+ await post("/session/end", { sessionId: sid, final: true });
void post("/crystals/auto", { olderThanDays: 7 }, 30000);
void post("/consolidate-pipeline", { tier: "all", force: true }, 30000);
if (sid === activeSessionId) activeSessionId = null;
diff --git a/plugin/scripts/session-end.mjs b/plugin/scripts/session-end.mjs
index 9e98b275..0f860c0d 100755
--- a/plugin/scripts/session-end.mjs
+++ b/plugin/scripts/session-end.mjs
@@ -113,7 +113,10 @@ async function main() {
fetch(`${REST_URL}/agentmemory/session/end`, {
method: "POST",
headers: authHeaders(),
- body: JSON.stringify({ sessionId }),
+ body: JSON.stringify({
+ sessionId,
+ final: true
+ }),
signal: AbortSignal.timeout(3e4)
}).catch(() => {});
if (process.env["CLAUDE_MEMORY_BRIDGE"] === "true") fetch(`${REST_URL}/agentmemory/claude-bridge/sync`, {
diff --git a/plugin/scripts/stop.mjs b/plugin/scripts/stop.mjs
index 0b4f370f..e9998bae 100755
--- a/plugin/scripts/stop.mjs
+++ b/plugin/scripts/stop.mjs
@@ -97,7 +97,10 @@ async function main() {
fetch(`${REST_URL}/agentmemory/session/end`, {
method: "POST",
headers: authHeaders(),
- body: JSON.stringify({ sessionId }),
+ body: JSON.stringify({
+ sessionId,
+ final: false
+ }),
signal: AbortSignal.timeout(5e3)
}).catch(() => {});
setTimeout(() => process.exit(0), 1500).unref();
diff --git a/plugin/skills/agentmemory-config/REFERENCE.md b/plugin/skills/agentmemory-config/REFERENCE.md
index 656dcf19..e2ab6379 100644
--- a/plugin/skills/agentmemory-config/REFERENCE.md
+++ b/plugin/skills/agentmemory-config/REFERENCE.md
@@ -3,7 +3,7 @@
Generated by scanning `src/` for `AGENTMEMORY_*` usage. Do not edit the block below by hand; run `npm run skills:gen` after adding or removing a variable. Internal markers ending in two underscores are excluded.
<!-- AUTOGEN:env START - generated by scripts/skills/generate.ts, do not edit by hand -->
-Configuration is read from the environment and from `~/.agentmemory/.env` (no `export` prefix). 72 recognized variables:
+Configuration is read from the environment and from `~/.agentmemory/.env` (no `export` prefix). 73 recognized variables:
- `AGENTMEMORY_AGENT_SCOPE`
- `AGENTMEMORY_ALLOW_AGENT_SDK`
@@ -36,6 +36,7 @@ Configuration is read from the environment and from `~/.agentmemory/.env` (no `e
- `AGENTMEMORY_DOCKER_UID`
- `AGENTMEMORY_DROP_STALE_INDEX`
- `AGENTMEMORY_EXPORT_ROOT`
+- `AGENTMEMORY_FINALIZE_IDLE_MS`
- `AGENTMEMORY_FOLLOWUP_WINDOW_SECONDS`
- `AGENTMEMORY_FORCE_PROXY`
- `AGENTMEMORY_GRAPH_COMPACT_ON_BOOT`
diff --git a/scripts/docs-sync.state.json b/scripts/docs-sync.state.json
index 4fab8b88..075517cb 100644
--- a/scripts/docs-sync.state.json
+++ b/scripts/docs-sync.state.json
@@ -20,13 +20,13 @@
"12"
],
"tests": [
- "2500+"
+ "2600+"
],
"functions": [
- "311"
+ "312"
],
"sourceFiles": [
- "219"
+ "220"
],
"loc": [
"52000"
diff --git a/src/cli.ts b/src/cli.ts
index 067a324a..d626a8c6 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -2894,7 +2894,7 @@ async function seedDemoSession(
}
}
- await postJsonStrict(`${base}/agentmemory/session/end`, { sessionId: session.id });
+ await postJsonStrict(`${base}/agentmemory/session/end`, { sessionId: session.id, final: true });
return stored;
}
diff --git a/src/config.ts b/src/config.ts
index 5b6c4a24..d2ccdc89 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -249,6 +249,12 @@ export function getSessionSweepStaleHours(): number {
return parsed > 0 ? parsed : 24;
}
+export function getFinalizeIdleMs(): number {
+ const raw = getMergedEnv()["AGENTMEMORY_FINALIZE_IDLE_MS"];
+ if (!raw || !/^\d+$/.test(raw.trim())) return 120000;
+ return parseInt(raw.trim(), 10);
+}
+
export function isGraphCompactOnBootEnabled(): boolean {
return getMergedEnv()["AGENTMEMORY_GRAPH_COMPACT_ON_BOOT"] !== "false";
}
diff --git a/src/functions/compress-synthetic.ts b/src/functions/compress-synthetic.ts
index d7884e7c..6b13f932 100644
--- a/src/functions/compress-synthetic.ts
+++ b/src/functions/compress-synthetic.ts
@@ -87,6 +87,7 @@ export function buildSyntheticCompression(
id: raw.id,
sessionId: raw.sessionId,
timestamp: raw.timestamp,
+ compressedAt: new Date().toISOString(),
type: inferType(toolName, raw.hookType),
title: truncate(toolName || "observation", 80),
subtitle: inputStr ? truncate(inputStr, 120) : undefined,
diff --git a/src/functions/compress.ts b/src/functions/compress.ts
index 4dfb0732..eb30b1ce 100644
--- a/src/functions/compress.ts
+++ b/src/functions/compress.ts
@@ -167,6 +167,7 @@ export function registerCompressFunction(
id: data.observationId,
sessionId: data.sessionId,
timestamp: data.raw.timestamp,
+ compressedAt: new Date().toISOString(),
...scrubRecord(parsed),
confidence: qualityScore / 100,
source: createObservationSource(data.raw),
diff --git a/src/functions/observe.ts b/src/functions/observe.ts
index 237fd2c7..2b695d89 100644
--- a/src/functions/observe.ts
+++ b/src/functions/observe.ts
@@ -304,7 +304,7 @@ export function registerObserveFunction(
value: (session.observationCount || 0) + 1,
},
];
- if (session.status === "abandoned") {
+ if (session.status !== "active") {
updates.push({ type: "set", path: "status", value: "active" });
updates.push({ type: "remove", path: "endedAt" });
}
diff --git a/src/functions/session-finalize.ts b/src/functions/session-finalize.ts
new file mode 100644
index 00000000..5d6e49be
--- /dev/null
+++ b/src/functions/session-finalize.ts
@@ -0,0 +1,146 @@
+import { TriggerAction, type IIIClient } from "iii-sdk";
+import type { StateKV } from "../state/kv.js";
+import { KV } from "../state/schema.js";
+import { withKeyedLock } from "../state/keyed-mutex.js";
+import type { Session } from "../types.js";
+import { logger } from "../logger.js";
+import { getFinalizeIdleMs } from "../config.js";
+
+export const FINALIZE_DUE_KEY = "finalize:due";
+export const FINALIZE_TICK_MS = 30_000;
+const FINALIZE_BATCH = 50;
+
+type FinalizeDue = Record<string, number>;
+
+export interface SessionFinalizeResult {
+ success: boolean;
+ due: number;
+ finalized: number;
+ rescheduled: number;
+ dropped: number;
+ failed: number;
+ error?: string;
+}
+
+async function readDue(kv: StateKV): Promise<FinalizeDue> {
+ const record = await kv.get<FinalizeDue>(KV.config, FINALIZE_DUE_KEY).catch(() => null);
+ if (!record || typeof record !== "object") return {};
+ const due: FinalizeDue = {};
+ for (const [sessionId, at] of Object.entries(record)) {
+ if (typeof at === "number" && Number.isFinite(at)) due[sessionId] = at;
+ }
+ return due;
+}
+
+export function scheduleSessionFinalize(
+ kv: StateKV,
+ sessionId: string,
+ dueAt: number = Date.now() + getFinalizeIdleMs(),
+): Promise<number> {
+ return withKeyedLock(FINALIZE_DUE_KEY, async () => {
+ const due = await readDue(kv);
+ due[sessionId] = dueAt;
+ await kv.set(KV.config, FINALIZE_DUE_KEY, due);
+ return dueAt;
+ });
+}
+
+export function clearSessionFinalize(kv: StateKV, sessionId: string): Promise<void> {
+ return withKeyedLock(FINALIZE_DUE_KEY, async () => {
+ const due = await readDue(kv);
+ if (!(sessionId in due)) return;
+ delete due[sessionId];
+ await kv.set(KV.config, FINALIZE_DUE_KEY, due);
+ });
+}
+
+function lastActivityMs(session: Session): number {
+ const ts = new Date(session.updatedAt ?? session.startedAt).getTime();
+ return Number.isFinite(ts) ? ts : 0;
+}
+
+export function registerSessionFinalizeFunction(sdk: IIIClient, kv: StateKV): void {
+ sdk.registerFunction(
+ "mem::session-finalize",
+ async (data?: { now?: number }): Promise<SessionFinalizeResult> => {
+ const now = typeof data?.now === "number" ? data.now : Date.now();
+ const idleMs = getFinalizeIdleMs();
+ const due = await readDue(kv);
+ const dueCount = Object.keys(due).length;
+ const ready = Object.entries(due)
+ .filter(([, at]) => at <= now)
+ .sort((a, b) => a[1] - b[1])
+ .slice(0, FINALIZE_BATCH);
+
+ let finalized = 0;
+ let rescheduled = 0;
+ let dropped = 0;
+ let failed = 0;
+ for (const [sessionId] of ready) {
+ try {
+ const outcome = await withKeyedLock(`obs:${sessionId}`, async () => {
+ const session = await kv.get<Session>(KV.sessions, sessionId);
+ if (!session || session.id !== sessionId || session.status !== "active") {
+ return "drop" as const;
+ }
+ const idleUntil = lastActivityMs(session) + idleMs;
+ if (idleUntil > now) return idleUntil;
+ await kv.update(KV.sessions, sessionId, [
+ { type: "set", path: "endedAt", value: new Date(now).toISOString() },
+ { type: "set", path: "status", value: "completed" },
+ ]);
+ return "ended" as const;
+ });
+ if (typeof outcome === "number") {
+ await scheduleSessionFinalize(kv, sessionId, outcome);
+ rescheduled++;
+ continue;
+ }
+ await clearSessionFinalize(kv, sessionId);
+ if (outcome === "drop") {
+ dropped++;
+ continue;
+ }
+ finalized++;
+ void sdk
+ .trigger({
+ function_id: "event::session::stopped",
+ payload: { sessionId },
+ action: TriggerAction.Void(),
+ })
+ .catch((err) => {
+ logger.warn("event::session::stopped trigger failed", {
+ sessionId,
+ error: err instanceof Error ? err.message : String(err),
+ });
+ });
+ } catch (err) {
+ failed++;
+ logger.warn("Session finalize failed", {
+ sessionId,
+ error: err instanceof Error ? err.message : String(err),
+ });
+ }
+ }
+
+ if (finalized > 0 || failed > 0) {
+ logger.info("Idle sessions finalized", {
+ due: dueCount,
+ finalized,
+ rescheduled,
+ dropped,
+ failed,
+ });
+ }
+ return {
+ success: failed === 0,
+ due: dueCount,
+ finalized,
+ rescheduled,
+ dropped,
+ failed,
+ ...(failed > 0 ? { error: `${failed} session finalize(s) failed` } : {}),
+ };
+ },
+ );
+}
diff --git a/src/functions/session-sweep.ts b/src/functions/session-sweep.ts
index 43da742b..5ade2985 100644
--- a/src/functions/session-sweep.ts
+++ b/src/functions/session-sweep.ts
@@ -1,10 +1,11 @@
-import type { IIIClient } from "iii-sdk";
+import { TriggerAction, type IIIClient } from "iii-sdk";
import type { StateKV } from "../state/kv.js";
import { KV } from "../state/schema.js";
import { withKeyedLock } from "../state/keyed-mutex.js";
import type { Session } from "../types.js";
import { logger } from "../logger.js";
import { safeAudit } from "./audit.js";
+import { clearSessionFinalize } from "./session-finalize.js";
import {
isSessionSweepEnabled,
getSessionSweepStaleHours,
@@ -50,16 +51,32 @@ export function registerSessionSweepFunction(sdk: IIIClient, kv: StateKV): void
for (const candidate of sessions) {
if (!isStaleActive(candidate, cutoff)) continue;
try {
- const marked = await withKeyedLock(`obs:${candidate.id}`, async () => {
+ const abandonedSession = await withKeyedLock(`obs:${candidate.id}`, async () => {
const current = await kv.get<Session>(KV.sessions, candidate.id);
- if (!isStaleActive(current, cutoff)) return false;
+ if (!isStaleActive(current, cutoff)) return null;
await kv.update(KV.sessions, candidate.id, [
{ type: "set", path: "status", value: "abandoned" },
{ type: "set", path: "endedAt", value: new Date().toISOString() },
]);
- return true;
+ return current;
});
- if (marked) abandonedIds.push(candidate.id);
+ if (!abandonedSession) continue;
+ abandonedIds.push(candidate.id);
+ await clearSessionFinalize(kv, candidate.id).catch(() => {});
+ if ((abandonedSession.observationCount ?? 0) > 0) {
+ void sdk
+ .trigger({
+ function_id: "event::session::stopped",
+ payload: { sessionId: candidate.id, skipConsolidation: true },
+ action: TriggerAction.Void(),
+ })
+ .catch((err) => {
+ logger.warn("event::session::stopped trigger failed", {
+ sessionId: candidate.id,
+ error: err instanceof Error ? err.message : String(err),
+ });
+ });
+ }
} catch (err) {
failed++;
logger.warn("Session sweep update failed", {
diff --git a/src/functions/summarize.ts b/src/functions/summarize.ts
index 931f67c3..aaf8669c 100644
--- a/src/functions/summarize.ts
+++ b/src/functions/summarize.ts
@@ -224,6 +224,35 @@ function parseSummaryXml(
};
}
+function visibleAt(observation: CompressedObservation): string {
+ return observation.compressedAt ?? observation.timestamp;
+}
+
+async function reduceWithExisting(
+ provider: MemoryProvider,
+ existing: SessionSummary,
+ delta: SessionSummary,
+ total: number,
+): Promise<string> {
+ const existingEnd = Math.max(1, total - delta.observationCount);
+ const partial = (s: SessionSummary, obsRangeStart: number, obsRangeEnd: number) => ({
+ title: s.title,
+ narrative: s.narrative,
+ keyDecisions: s.keyDecisions,
+ filesModified: s.filesModified,
+ concepts: s.concepts,
+ obsRangeStart,
+ obsRangeEnd,
+ });
+ return provider.summarize(
+ REDUCE_SYSTEM,
+ buildReducePrompt([
+ partial(existing, 1, existingEnd),
+ partial(delta, existingEnd + 1, total),
+ ]),
+ );
+}
+
export function registerSummarizeFunction(
sdk: IIIClient,
kv: StateKV,
@@ -231,7 +260,7 @@ export function registerSummarizeFunction(
metricsStore?: MetricsStore,
): void {
sdk.registerFunction("mem::summarize",
- async (data: { sessionId: string } | undefined) => {
+ async (data: { sessionId: string; force?: boolean } | undefined) => {
const startMs = Date.now();
if (!data || typeof data.sessionId !== "string" || !data.sessionId.trim()) {
return { success: false, error: "sessionId is required" };
@@ -249,7 +278,9 @@ export function registerSummarizeFunction(
const observations = await kv.list<CompressedObservation>(
KV.observations(sessionId),
);
- const compressed = observations.filter((o) => o.title);
+ const compressed = observations
+ .filter((o) => o.title)
+ .sort((a, b) => visibleAt(a).localeCompare(visibleAt(b)) || a.id.localeCompare(b.id));
if (compressed.length === 0) {
logger.info("No observations to summarize", {
@@ -258,6 +289,22 @@ export function registerSummarizeFunction(
return { success: false, error: "no_observations" };
}
+ const existing =
+ data.force === true
+ ? null
+ : await kv.get<SessionSummary>(KV.summaries, sessionId).catch(() => null);
+ const watermark = existing?.coveredThrough;
+ const delta = watermark
+ ? compressed.filter((o) => visibleAt(o) > watermark)
+ : compressed;
+ if (existing && watermark && delta.length === 0) {
+ return { success: true, unchanged: true, summary: existing };
+ }
+ const incremental =
+ existing && watermark && delta.length < compressed.length ? existing : null;
+ const input = incremental ? delta : compressed;
+ const coveredThrough = visibleAt(compressed[compressed.length - 1]);
+
if (isNoopProvider(provider)) {
logger.info("Summarize skipped — no LLM provider configured", {
sessionId,
@@ -278,12 +325,12 @@ export function registerSummarizeFunction(
for (let attempt = 1; attempt <= 2; attempt++) {
const produced = await produceSummaryXml(
provider,
- compressed,
+ input,
sessionId,
session.project,
);
response = produced.response;
- mode = produced.mode;
+ mode = incremental ? "incremental" : produced.mode;
chunks = produced.chunks;
if (!response || !response.trim()) {
logger.warn("Empty provider response on summarize", {
@@ -291,7 +338,7 @@ export function registerSummarizeFunction(
provider: provider.name,
mode,
chunks,
- observationCount: compressed.length,
+ observationCount: input.length,
attempt,
});
continue;
@@ -300,8 +347,12 @@ export function registerSummarizeFunction(
response,
sessionId,
session.project,
- compressed.length,
+ input.length,
);
+ if (summary && incremental) {
+ response = await reduceWithExisting(provider, incremental, summary, compressed.length);
+ summary = parseSummaryXml(response, sessionId, session.project, compressed.length);
+ }
if (summary) break;
logger.warn("Failed to parse summary XML", { sessionId, attempt });
}
@@ -321,7 +372,7 @@ export function registerSummarizeFunction(
}
return { success: false, error: "parse_failed" };
}
- summary = scrubRecord(summary);
+ summary = scrubRecord({ ...summary, observationCount: compressed.length, coveredThrough });
const summaryForValidation = {
title: summary.title,
@@ -354,6 +405,7 @@ export function registerSummarizeFunction(
await safeAudit(kv, "compress", "mem::summarize", [sessionId], {
title: summary.title,
observationCount: compressed.length,
+ newObservations: input.length,
});
const latencyMs = Date.now() - startMs;
@@ -374,7 +426,7 @@ export function registerSummarizeFunction(
valid: validation.valid,
});
- return { success: true, summary, qualityScore };
+ return { success: true, summary, qualityScore, incremental: incremental !== null };
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
const latencyMs = Date.now() - startMs;
diff --git a/src/hooks/session-end.ts b/src/hooks/session-end.ts
index 8de00319..ecd8043b 100644
--- a/src/hooks/session-end.ts
+++ b/src/hooks/session-end.ts
@@ -94,7 +94,7 @@ async function main() {
fetch(`${REST_URL}/agentmemory/session/end`, {
method: "POST",
headers: authHeaders(),
- body: JSON.stringify({ sessionId }),
+ body: JSON.stringify({ sessionId, final: true }),
signal: AbortSignal.timeout(30000),
}).catch(() => {});
diff --git a/src/hooks/stop.ts b/src/hooks/stop.ts
index d67e54a4..968acb9a 100644
--- a/src/hooks/stop.ts
+++ b/src/hooks/stop.ts
@@ -44,7 +44,7 @@ async function main() {
fetch(`${REST_URL}/agentmemory/session/end`, {
method: "POST",
headers: authHeaders(),
- body: JSON.stringify({ sessionId }),
+ body: JSON.stringify({ sessionId, final: false }),
signal: AbortSignal.timeout(5000),
}).catch(() => {});
diff --git a/src/index.ts b/src/index.ts
index cc59d46d..0137ca99 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -20,6 +20,7 @@ import {
isSessionSweepEnabled,
isGraphCompactOnBootEnabled,
getSessionSweepStaleHours,
+ getFinalizeIdleMs,
} from "./config.js";
import {
createProvider,
@@ -71,6 +72,7 @@ import { registerTimelineFunction } from "./functions/timeline.js";
import { registerSmartSearchFunction } from "./functions/smart-search.js";
import { registerRecentSearchesSweepFunction } from "./functions/recent-searches-sweep.js";
import { registerSessionSweepFunction } from "./functions/session-sweep.js";
+import { FINALIZE_TICK_MS, registerSessionFinalizeFunction } from "./functions/session-finalize.js";
import { registerProfileFunction } from "./functions/profile.js";
import { registerAutoForgetFunction } from "./functions/auto-forget.js";
import { registerExportImportFunction } from "./functions/export-import.js";
@@ -299,6 +301,7 @@ async function main() {
registerRememberFunction(sdk, kv);
registerEvictFunction(sdk, kv);
registerSessionSweepFunction(sdk, kv);
+ registerSessionFinalizeFunction(sdk, kv);
registerRelationsFunction(sdk, kv);
registerTimelineFunction(sdk, kv);
@@ -720,6 +723,19 @@ async function main() {
bootLog(`Session sweep: enabled (hourly, stale after ${getSessionSweepStaleHours()}h)`);
}
+ const finalizeIdleMs = getFinalizeIdleMs();
+ if (finalizeIdleMs > 0) {
+ const sessionFinalizeTimer = setInterval(async () => {
+ try {
+ await sdk.trigger({ function_id: "mem::session-finalize", payload: {} });
+ } catch (err) {
+ bootLog(`Session finalize failed: ${err instanceof Error ? err.message : String(err)}`);
+ }
+ }, FINALIZE_TICK_MS);
+ sessionFinalizeTimer.unref();
+ bootLog(`Session finalize: idle sessions complete after ${Math.round(finalizeIdleMs / 1000)}s`);
+ }
+
if (isConsolidationEnabled()) {
const consolidationTimer = setInterval(async () => {
try {
diff --git a/src/triggers/api.ts b/src/triggers/api.ts
index 80885c8f..3147c3cf 100644
--- a/src/triggers/api.ts
+++ b/src/triggers/api.ts
@@ -51,7 +51,9 @@ import { logger } from "../logger.js";
import { isValidEventId } from "../capture/event-id.js";
import { getCaptureController, type CaptureResult } from "../functions/capture.js";
import { withoutObservationSource } from "../functions/observation-source.js";
+import { clearSessionFinalize, scheduleSessionFinalize } from "../functions/session-finalize.js";
import {
+ getFinalizeIdleMs,
isGraphExtractionEnabled,
isConsolidationEnabled,
getConsolidationIntervalMs,
@@ -1110,14 +1112,47 @@ export function registerApiTriggers(
});
sdk.registerFunction("api::session::end",
- async (req: HttpRequest<{ sessionId: string }>): Promise<Response> => {
- const sessionId = asNonEmptyString((req.body as Record<string, unknown>)?.sessionId);
+ async (req: HttpRequest<{ sessionId: string; final?: boolean }>): Promise<Response> => {
+ const body = req.body as Record<string, unknown> | undefined;
+ const sessionId = asNonEmptyString(body?.sessionId);
if (!sessionId) {
return {
status_code: 400,
body: { error: "sessionId is required and must be a non-empty string" },
};
}
+ if (body?.final === false && getFinalizeIdleMs() > 0) {
+ const deferResult = await withKeyedLock(`obs:${sessionId}`, async () => {
+ const session = await kv.get<Session>(KV.sessions, sessionId);
+ if (!session || session.id !== sessionId) return "not_found" as const;
+ if (session.status === "completed") return "already_completed" as const;
+ const updates: Array<{ type: "set" | "remove"; path: string; value?: unknown }> = [
+ { type: "set", path: "updatedAt", value: new Date().toISOString() },
+ ];
+ if (session.status === "abandoned") {
+ updates.push({ type: "set", path: "status", value: "active" });
+ updates.push({ type: "remove", path: "endedAt" });
+ }
+ await kv.update(KV.sessions, sessionId, updates);
+ return "deferred" as const;
+ });
+ if (deferResult !== "deferred") {
+ return {
+ status_code: 200,
+ body: { success: true, ended: false, reason: deferResult },
+ };
+ }
+ const finalizeAt = await scheduleSessionFinalize(kv, sessionId);
+ return {
+ status_code: 200,
+ body: {
+ success: true,
+ ended: false,
+ reason: "deferred",
+ finalizeAt: new Date(finalizeAt).toISOString(),
+ },
+ };
+ }
const endResult = await withKeyedLock(`obs:${sessionId}`, async () => {
const session = await kv.get<Session>(KV.sessions, sessionId);
if (!session || session.id !== sessionId) return "not_found" as const;
@@ -1135,6 +1170,7 @@ export function registerApiTriggers(
body: { success: true, ended: false, reason: endResult },
};
}
+ await clearSessionFinalize(kv, sessionId).catch(() => {});
// Fan out session-stopped lifecycle (non-blocking).
try {
sdk.trigger({
diff --git a/src/triggers/events.ts b/src/triggers/events.ts
index 9a271ce3..352ed46b 100644
--- a/src/triggers/events.ts
+++ b/src/triggers/events.ts
@@ -120,7 +120,11 @@ export function registerEventTriggers(sdk: IIIClient, kv: StateKV): void {
});
sdk.registerFunction("event::session::stopped", async (data: { sessionId: string; skipConsolidation?: boolean }) => {
- const summary = await sdk.trigger({ function_id: "mem::summarize", payload: data });
+ const summary = await sdk.trigger<typeof data, { unchanged?: boolean } | undefined>({
+ function_id: "mem::summarize",
+ payload: data,
+ });
+ if (summary?.unchanged === true) return summary;
const fireVoid = (function_id: string, payload: unknown) =>
sdk
.trigger({ function_id, payload, action: TriggerAction.Void() })
diff --git a/src/types.ts b/src/types.ts
index f9a1298f..a14daf92 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -103,6 +103,7 @@ export interface CompressedObservation {
agentId?: string;
origin?: Origin;
captureKey?: string;
+ compressedAt?: string;
}
export type ObservationType =
@@ -157,6 +158,7 @@ export interface SessionSummary {
filesModified: string[];
concepts: string[];
observationCount: number;
+ coveredThrough?: string;
}
export type HookType =
diff --git a/test/live-source-budget.test.ts b/test/live-source-budget.test.ts
index 7dfc85ac..99587013 100644
--- a/test/live-source-budget.test.ts
+++ b/test/live-source-budget.test.ts
@@ -83,7 +83,7 @@ describe.each(["observe", "compress"] as const)("live %s source budget", (mode)
expect(payloadByteLength(first.source)).toBeLessThan(payloadByteLength(buildSyntheticCompression(raw("unbounded")).source));
const second = await r.write();
expect(second.source).toBeUndefined();
- expect(withoutObservationSource(second)).toEqual({ ...expected, id: second.id });
+ expect(withoutObservationSource(second)).toEqual({ ...expected, id: second.id, compressedAt: second.compressedAt });
const rows = await r.kv.list(scope);
expect(sourceBytes(rows)).toBeLessThanOrEqual(SESSION_SOURCE_MAX_BYTES);
expect(payloadByteLength({ result: rows })).toBeLessThan(SAFE_PAYLOAD_BYTES);
@@ -109,7 +109,7 @@ describe.each(["observe", "compress"] as const)("live %s source budget", (mode)
await r.kv.set(scope, seed.id, seed);
const saved = await r.write();
expect(saved.source).toBeUndefined();
- expect(withoutObservationSource(saved)).toEqual({ ...expected, id: saved.id });
+ expect(withoutObservationSource(saved)).toEqual({ ...expected, id: saved.id, compressedAt: saved.compressedAt });
});
});
diff --git a/test/observe-reactivate-abandoned.test.ts b/test/observe-reactivate-abandoned.test.ts
index 0416b6b8..2bafb6f7 100644
--- a/test/observe-reactivate-abandoned.test.ts
+++ b/test/observe-reactivate-abandoned.test.ts
@@ -122,4 +122,30 @@ describe("observe reactivates abandoned sessions", () => {
expect(session.endedAt).toBeUndefined();
expect(session.observationCount).toBe(4);
});
+
+ it("reopens a completed session when a later turn captures more", async () => {
+ const { registerObserveFunction } = await import("../src/functions/observe.js");
+ const sdk = mockSdk();
+ const kv = mockKV();
+ seedSession(kv.store, "ses_completed", "completed");
+ kv.store.get("mem:sessions")!.set("ses_completed", {
+ ...(kv.store.get("mem:sessions")!.get("ses_completed") as Record<string, unknown>),
+ endedAt: new Date(Date.now() - 60 * 1000).toISOString(),
+ });
+ registerObserveFunction(sdk as never, kv as never);
+
+ await sdk.trigger("mem::observe", {
+ sessionId: "ses_completed",
+ project: "/home/user/myrepo",
+ cwd: "/home/user/myrepo",
+ hookType: "post_tool_use",
+ timestamp: new Date().toISOString(),
+ data: { tool_name: "Edit", tool_input: { file_path: "z.ts" } },
+ });
+
+ const session = kv.store.get("mem:sessions")!.get("ses_completed") as Record<string, unknown>;
+ expect(session.status).toBe("active");
+ expect("endedAt" in session).toBe(false);
+ expect(session.observationCount).toBe(4);
+ });
});
diff --git a/test/session-finalize.test.ts b/test/session-finalize.test.ts
new file mode 100644
index 00000000..7ec1fcce
--- /dev/null
+++ b/test/session-finalize.test.ts
@@ -0,0 +1,172 @@
+import { describe, it, expect, beforeEach, vi } from "vitest";
+
+vi.mock("../src/logger.js", () => ({
+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
+}));
+
+import {
+ FINALIZE_DUE_KEY,
+ clearSessionFinalize,
+ registerSessionFinalizeFunction,
+ scheduleSessionFinalize,
+} from "../src/functions/session-finalize.js";
+import { KV } from "../src/state/schema.js";
+import type { Session } from "../src/types.js";
+
+function mockKV() {
+ const store = new Map<string, Map<string, unknown>>();
+ return {
+ store,
+ get: async <T>(scope: string, key: string): Promise<T | null> =>
+ (store.get(scope)?.get(key) as T) ?? null,
+ set: async <T>(scope: string, key: string, data: T): Promise<T> => {
+ if (!store.has(scope)) store.set(scope, new Map());
+ store.get(scope)!.set(key, data);
+ return data;
+ },
+ update: async (
+ scope: string,
+ key: string,
+ ops: Array<{ type: "set" | "remove"; path: string; value?: unknown }>,
+ ): Promise<void> => {
+ const row = store.get(scope)?.get(key) as Record<string, unknown> | undefined;
+ if (!row) return;
+ for (const op of ops) {
+ if (op.type === "remove") delete row[op.path];
+ else row[op.path] = op.value;
+ }
+ },
+ delete: async (scope: string, key: string): Promise<void> => {
+ store.get(scope)?.delete(key);
+ },
+ list: async <T>(scope: string): Promise<T[]> =>
+ Array.from(store.get(scope)?.values() ?? []) as T[],
+ };
+}
+
+function mockSdk() {
+ const functions = new Map<string, Function>();
+ const triggers: Array<{ function_id: string; payload: unknown }> = [];
+ return {
+ triggers,
+ registerFunction: (id: string, handler: Function) => {
+ functions.set(id, handler);
+ },
+ registerTrigger: () => {},
+ trigger: async (input: { function_id: string; payload: unknown }) => {
+ triggers.push(input);
+ const fn = functions.get(input.function_id);
+ return fn ? fn(input.payload) : undefined;
+ },
+ };
+}
+
+const nowMs = Date.UTC(2026, 9, 8, 12, 0, 0);
+const MIN = 60_000;
+const IDLE_MS = 120_000;
+
+function session(partial: Partial<Session>): Session {
+ return {
+ id: "s1",
+ project: "/proj",
+ cwd: "/proj",
+ startedAt: new Date(nowMs - 60 * MIN).toISOString(),
+ status: "active",
+ observationCount: 4,
+ ...partial,
+ };
+}
+
+function stoppedTriggers(sdk: ReturnType<typeof mockSdk>) {
+ return sdk.triggers.filter((t) => t.function_id === "event::session::stopped");
+}
+
+describe("mem::session-finalize", () => {
+ let kv: ReturnType<typeof mockKV>;
+ let sdk: ReturnType<typeof mockSdk>;
+
+ beforeEach(() => {
+ vi.unstubAllEnvs();
+ vi.stubEnv("AGENTMEMORY_FINALIZE_IDLE_MS", String(IDLE_MS));
+ kv = mockKV();
+ sdk = mockSdk();
+ registerSessionFinalizeFunction(sdk as never, kv as never);
+ });
+
+ it("keeps every due entry in one config record", async () => {
+ await scheduleSessionFinalize(kv as never, "s1", nowMs + MIN);
+ await scheduleSessionFinalize(kv as never, "s2", nowMs + 2 * MIN);
+ expect(await kv.get(KV.config, FINALIZE_DUE_KEY)).toEqual({ s1: nowMs + MIN, s2: nowMs + 2 * MIN });
+
+ await clearSessionFinalize(kv as never, "s1");
+ expect(await kv.get(KV.config, FINALIZE_DUE_KEY)).toEqual({ s2: nowMs + 2 * MIN });
+ });
+
+ it("completes an idle session once its entry is due and publishes the stopped lifecycle", async () => {
+ await kv.set(KV.sessions, "s1", session({ updatedAt: new Date(nowMs - 3 * MIN).toISOString() }));
+ await scheduleSessionFinalize(kv as never, "s1", nowMs - 1);
+
+ const result = await sdk.trigger({ function_id: "mem::session-finalize", payload: { now: nowMs } });
+
+ expect(result).toMatchObject({ success: true, due: 1, finalized: 1, rescheduled: 0, dropped: 0 });
+ const updated = await kv.get<Session>(KV.sessions, "s1");
+ expect(updated!.status).toBe("completed");
+ expect(updated!.endedAt).toBe(new Date(nowMs).toISOString());
+ expect(stoppedTriggers(sdk)).toEqual([
+ expect.objectContaining({ function_id: "event::session::stopped", payload: { sessionId: "s1" } }),
+ ]);
+ expect(await kv.get(KV.config, FINALIZE_DUE_KEY)).toEqual({});
+ });
+
+ it("pushes a session that was active after its entry was written to the next idle window", async () => {
+ const activeAt = nowMs - 30_000;
+ await kv.set(KV.sessions, "s1", session({ updatedAt: new Date(activeAt).toISOString() }));
+ await scheduleSessionFinalize(kv as never, "s1", nowMs - 1);
+
+ const result = await sdk.trigger({ function_id: "mem::session-finalize", payload: { now: nowMs } });
+
+ expect(result).toMatchObject({ finalized: 0, rescheduled: 1 });
+ expect((await kv.get<Session>(KV.sessions, "s1"))!.status).toBe("active");
+ expect(await kv.get(KV.config, FINALIZE_DUE_KEY)).toEqual({ s1: activeAt + IDLE_MS });
+ expect(stoppedTriggers(sdk)).toHaveLength(0);
+ });
+
+ it("drops entries for sessions that are already completed or gone", async () => {
+ await kv.set(
+ KV.sessions,
+ "done",
+ session({ id: "done", status: "completed", updatedAt: new Date(nowMs - 10 * MIN).toISOString() }),
+ );
+ await scheduleSessionFinalize(kv as never, "done", nowMs - 1);
+ await scheduleSessionFinalize(kv as never, "missing", nowMs - 1);
+
+ const result = await sdk.trigger({ function_id: "mem::session-finalize", payload: { now: nowMs } });
+
+ expect(result).toMatchObject({ finalized: 0, dropped: 2 });
+ expect(await kv.get(KV.config, FINALIZE_DUE_KEY)).toEqual({});
+ expect(stoppedTriggers(sdk)).toHaveLength(0);
+ });
+
+ it("leaves entries that are not due yet untouched", async () => {
+ await kv.set(KV.sessions, "s1", session({ updatedAt: new Date(nowMs - 10 * MIN).toISOString() }));
+ await scheduleSessionFinalize(kv as never, "s1", nowMs + MIN);
+
+ const result = await sdk.trigger({ function_id: "mem::session-finalize", payload: { now: nowMs } });
+
+ expect(result).toMatchObject({ due: 1, finalized: 0, rescheduled: 0, dropped: 0 });
+ expect((await kv.get<Session>(KV.sessions, "s1"))!.status).toBe("active");
+ expect(await kv.get(KV.config, FINALIZE_DUE_KEY)).toEqual({ s1: nowMs + MIN });
+ });
+
+ it("finalizes from the stored record alone, so a restart does not lose pending sessions", async () => {
+ await kv.set(KV.sessions, "s1", session({ updatedAt: new Date(nowMs - 10 * MIN).toISOString() }));
+ await scheduleSessionFinalize(kv as never, "s1", nowMs - 1);
+
+ const restarted = mockSdk();
+ registerSessionFinalizeFunction(restarted as never, kv as never);
+ const result = await restarted.trigger({ function_id: "mem::session-finalize", payload: { now: nowMs } });
+
+ expect(result).toMatchObject({ finalized: 1 });
+ expect(stoppedTriggers(restarted)).toHaveLength(1);
+ });
+});
diff --git a/test/session-lifecycle-api.test.ts b/test/session-lifecycle-api.test.ts
index 0fe7081f..9aad54db 100644
--- a/test/session-lifecycle-api.test.ts
+++ b/test/session-lifecycle-api.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, it, vi } from "vitest";
+import { afterEach, describe, expect, it, vi } from "vitest";
vi.mock("iii-sdk", async (importOriginal) => {
const actual = await importOriginal<typeof import("iii-sdk")>();
@@ -244,3 +244,86 @@ describe("event::session::ended", () => {
});
});
});
+
+describe("api::session::end with final", () => {
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ });
+
+ it("keeps the session open on a per-turn end and schedules the idle finalizer", async () => {
+ const sessionId = "agent:dmp-pm:direct:turn";
+ const harness = makeHarness([[sessionId, session(sessionId)]]);
+ const handler = harness.functions.get("api::session::end")!;
+
+ const response = (await handler({ body: { sessionId, final: false } })) as ApiResponse;
+
+ expect(response.status_code).toBe(200);
+ expect(response.body).toEqual({
+ success: true,
+ ended: false,
+ reason: "deferred",
+ finalizeAt: expect.any(String),
+ });
+ expect(harness.store.get(KV.sessions)?.get(sessionId)).toMatchObject({
+ status: "active",
+ updatedAt: expect.any(String),
+ });
+ expect(harness.kv.set).toHaveBeenCalledWith(KV.config, "finalize:due", {
+ [sessionId]: expect.any(Number),
+ });
+ expect(harness.trigger).not.toHaveBeenCalled();
+ });
+
+ it("reopens an abandoned session on a per-turn end", async () => {
+ const sessionId = "agent:dmp-pm:direct:abandoned";
+ const row = { ...session(sessionId, "abandoned"), endedAt: "2026-08-26T01:00:00.000Z" };
+ const harness = makeHarness([[sessionId, row]]);
+ const handler = harness.functions.get("api::session::end")!;
+
+ const response = (await handler({ body: { sessionId, final: false } })) as ApiResponse;
+
+ expect(response.body).toMatchObject({ ended: false, reason: "deferred" });
+ const stored = harness.store.get(KV.sessions)?.get(sessionId) as Record<string, unknown>;
+ expect(stored.status).toBe("active");
+ expect("endedAt" in stored).toBe(false);
+ });
+
+ it("reports an already completed session on a per-turn end without touching it", async () => {
+ const sessionId = "agent:dmp-pm:direct:completed";
+ const harness = makeHarness([[sessionId, session(sessionId, "completed")]]);
+ const handler = harness.functions.get("api::session::end")!;
+
+ const response = (await handler({ body: { sessionId, final: false } })) as ApiResponse;
+
+ expect(response.body).toEqual({ success: true, ended: false, reason: "already_completed" });
+ expect(harness.update).not.toHaveBeenCalled();
+ expect(harness.kv.set).not.toHaveBeenCalled();
+ });
+
+ it("completes on every end when the idle window is zero", async () => {
+ vi.stubEnv("AGENTMEMORY_FINALIZE_IDLE_MS", "0");
+ const sessionId = "agent:dmp-pm:direct:immediate";
+ const harness = makeHarness([[sessionId, session(sessionId)]]);
+ const handler = harness.functions.get("api::session::end")!;
+
+ const response = (await handler({ body: { sessionId, final: false } })) as ApiResponse;
+
+ expect(response.body).toEqual({ success: true, ended: true });
+ expect(harness.store.get(KV.sessions)?.get(sessionId)).toMatchObject({ status: "completed" });
+ expect(harness.trigger).toHaveBeenCalledWith(
+ expect.objectContaining({ function_id: "event::session::stopped" }),
+ );
+ });
+
+ it("completes at once on a final end", async () => {
+ const sessionId = "agent:dmp-pm:direct:final";
+ const harness = makeHarness([[sessionId, session(sessionId)]]);
+ const handler = harness.functions.get("api::session::end")!;
+
+ const response = (await handler({ body: { sessionId, final: true } })) as ApiResponse;
+
+ expect(response.body).toEqual({ success: true, ended: true });
+ expect(harness.store.get(KV.sessions)?.get(sessionId)).toMatchObject({ status: "completed" });
+ expect(harness.trigger).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/test/session-sweep.test.ts b/test/session-sweep.test.ts
index a155d7e1..43dda034 100644
--- a/test/session-sweep.test.ts
+++ b/test/session-sweep.test.ts
@@ -96,6 +96,21 @@ describe("mem::session-sweep", () => {
expect(sweep.success).toBe(true);
});
+ it("summarizes what a stale session captured before leaving it abandoned", async () => {
+ kv.set(
+ KV.sessions,
+ "s-obs",
+ session({ id: "s-obs", observationCount: 3, updatedAt: new Date(nowMs - 30 * H).toISOString() }),
+ );
+ kv.set(KV.sessions, "s-empty", session({ id: "s-empty", updatedAt: new Date(nowMs - 30 * H).toISOString() }));
+ const sweep = await (sdk as any).trigger({ function_id: "mem::session-sweep", payload: {} });
+ expect(sweep.abandoned).toBe(2);
+ const stopped = sdk.triggers.filter((t) => t.function_id === "event::session::stopped");
+ expect(stopped).toEqual([
+ expect.objectContaining({ payload: { sessionId: "s-obs", skipConsolidation: true } }),
+ ]);
+ });
+
it("falls back to startedAt when the session has no heartbeat", async () => {
kv.set(KV.sessions, "s-nobeat", session({ id: "s-nobeat", startedAt: new Date(nowMs - 48 * H).toISOString() }));
const sweep = await (sdk as any).trigger({ function_id: "mem::session-sweep", payload: {} });
diff --git a/test/summarize-watermark.test.ts b/test/summarize-watermark.test.ts
new file mode 100644
index 00000000..9074f433
--- /dev/null
+++ b/test/summarize-watermark.test.ts
@@ -0,0 +1,233 @@
+import { describe, it, expect, vi } from "vitest";
+
+vi.mock("../src/logger.js", () => ({
+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
+}));
+
+vi.mock("../src/state/schema.js", () => ({
+ KV: {
+ sessions: "sessions",
+ summaries: "summaries",
+ observations: (sessionId: string) => `obs:${sessionId}`,
+ audit: "audit",
+ },
+}));
+
+vi.mock("../src/eval/schemas.js", () => ({
+ SummaryOutputSchema: {},
+}));
+
+vi.mock("../src/eval/validator.js", () => ({
+ validateOutput: () => ({ valid: true, result: { errors: [] } }),
+}));
+
+vi.mock("../src/eval/quality.js", () => ({
+ scoreSummary: () => 100,
+}));
+
+vi.mock("../src/functions/audit.js", () => ({
+ safeAudit: vi.fn(),
+}));
+
+import { registerSummarizeFunction } from "../src/functions/summarize.js";
+import { REDUCE_SYSTEM, SUMMARY_SYSTEM } from "../src/prompts/summary.js";
+import type { CompressedObservation, MemoryProvider, Session, SessionSummary } from "../src/types.js";
+
+function mockKV() {
+ const store = new Map<string, Map<string, unknown>>();
+ return {
+ store,
+ get: async <T>(scope: string, key: string): Promise<T | null> =>
+ (store.get(scope)?.get(key) as T) ?? null,
+ set: async <T>(scope: string, key: string, data: T): Promise<T> => {
+ if (!store.has(scope)) store.set(scope, new Map());
+ store.get(scope)!.set(key, data);
+ return data;
+ },
+ delete: async (scope: string, key: string): Promise<void> => {
+ store.get(scope)?.delete(key);
+ },
+ list: async <T>(scope: string): Promise<T[]> => {
+ const entries = store.get(scope);
+ return entries ? (Array.from(entries.values()) as T[]) : [];
+ },
+ };
+}
+
+function mockSdk() {
+ const functions = new Map<string, Function>();
+ return {
+ functions,
+ registerFunction: (id: string, handler: Function) => {
+ functions.set(id, handler);
+ },
+ registerTrigger: () => {},
+ trigger: async () => ({}),
+ };
+}
+
+function at(minute: number): string {
+ return new Date(Date.UTC(2026, 9, 8, 12, minute, 0)).toISOString();
+}
+
+function makeObs(i: number, sessionId: string, visibleAt: string, timestamp = visibleAt): CompressedObservation {
+ return {
+ id: `obs_${String(i).padStart(3, "0")}`,
+ sessionId,
+ timestamp,
+ compressedAt: visibleAt,
+ type: "conversation",
+ title: `obs ${i}`,
+ facts: [`fact ${i}`],
+ narrative: `narrative for obs ${i}`,
+ concepts: [],
+ files: [`src/file_${i}.ts`],
+ importance: 5,
+ };
+}
+
+function summaryXml(title: string): string {
+ return `<summary><title>${title}</title><narrative>${title} narrative</narrative><decisions><decision>${title} decision</decision></decisions><files><file>src/a.ts</file></files><concepts><concept>${title}</concept></concepts></summary>`;
+}
+
+function makeProvider(): MemoryProvider & { calls: Array<{ system: string; user: string }> } {
+ const calls: Array<{ system: string; user: string }> = [];
+ return {
+ name: "test",
+ calls,
+ compress: async () => "",
+ summarize: async (system: string, user: string) => {
+ calls.push({ system, user });
+ return summaryXml(system === REDUCE_SYSTEM ? `merged ${calls.length}` : `summary ${calls.length}`);
+ },
+ };
+}
+
+async function setup(sessionId: string) {
+ const sdk = mockSdk();
+ const kv = mockKV();
+ const provider = makeProvider();
+ const session: Session = {
+ id: sessionId,
+ project: "test-project",
+ cwd: "/tmp",
+ startedAt: at(0),
+ status: "active",
+ observationCount: 0,
+ };
+ await kv.set("sessions", sessionId, session);
+ registerSummarizeFunction(sdk as never, kv as never, provider);
+ const handler = sdk.functions.get("mem::summarize")!;
+ const addObs = async (from: number, to: number, visibleMinute: (i: number) => number) => {
+ for (let i = from; i <= to; i++) {
+ const o = makeObs(i, sessionId, at(visibleMinute(i)));
+ await kv.set(`obs:${sessionId}`, o.id, o);
+ }
+ };
+ const stored = async () => (await kv.get<SessionSummary>("summaries", sessionId))!;
+ return { handler, kv, provider, addObs, stored };
+}
+
+describe("mem::summarize watermark", () => {
+ it("records how far the stored summary reaches", async () => {
+ const t = await setup("ses_first");
+ await t.addObs(1, 5, (i) => i);
+
+ const result = await t.handler({ sessionId: "ses_first" });
+
+ expect(result).toMatchObject({ success: true, incremental: false });
+ expect(t.provider.calls).toHaveLength(1);
+ expect(t.provider.calls[0].system).toBe(SUMMARY_SYSTEM);
+ const summary = await t.stored();
+ expect(summary.observationCount).toBe(5);
+ expect(summary.coveredThrough).toBe(at(5));
+ });
+
+ it("makes no LLM call when nothing was captured since the last summary", async () => {
+ const t = await setup("ses_same");
+ await t.addObs(1, 5, (i) => i);
+ await t.handler({ sessionId: "ses_same" });
+
+ const result = await t.handler({ sessionId: "ses_same" });
+
+ expect(result).toMatchObject({ success: true, unchanged: true });
+ expect(t.provider.calls).toHaveLength(1);
+ expect((result as { summary: SessionSummary }).summary.title).toBe("summary 1");
+ });
+
+ it("summarizes only the new observations and merges them into the stored summary", async () => {
+ const t = await setup("ses_delta");
+ await t.addObs(1, 5, (i) => i);
+ await t.handler({ sessionId: "ses_delta" });
+ await t.addObs(6, 8, (i) => i);
+
+ const result = await t.handler({ sessionId: "ses_delta" });
+
+ expect(result).toMatchObject({ success: true, incremental: true });
+ expect(t.provider.calls).toHaveLength(3);
+ const chunk = t.provider.calls[1];
+ expect(chunk.system).toBe(SUMMARY_SYSTEM);
+ expect(chunk.user).toContain("obs 6");
+ expect(chunk.user).toContain("obs 8");
+ expect(chunk.user).not.toContain("obs 1");
+ const reduce = t.provider.calls[2];
+ expect(reduce.system).toBe(REDUCE_SYSTEM);
+ expect(reduce.user).toContain("summary 1");
+ expect(reduce.user).toContain("summary 2");
+ const summary = await t.stored();
+ expect(summary.title).toBe("merged 3");
+ expect(summary.observationCount).toBe(8);
+ expect(summary.coveredThrough).toBe(at(8));
+ });
+
+ it("treats an observation compressed after the last summary as new even when its capture time is old", async () => {
+ const t = await setup("ses_late");
+ await t.addObs(1, 5, (i) => i);
+ await t.handler({ sessionId: "ses_late" });
+ const late = makeObs(99, "ses_late", at(9), at(2));
+ await t.kv.set("obs:ses_late", late.id, late);
+
+ const result = await t.handler({ sessionId: "ses_late" });
+
+ expect(result).toMatchObject({ success: true, incremental: true });
+ expect(t.provider.calls[1].user).toContain("obs 99");
+ expect((await t.stored()).coveredThrough).toBe(at(9));
+ });
+
+ it("re-reads everything when asked to force a summary", async () => {
+ const t = await setup("ses_force");
+ await t.addObs(1, 5, (i) => i);
+ await t.handler({ sessionId: "ses_force" });
+
+ const result = await t.handler({ sessionId: "ses_force", force: true });
+
+ expect(result).toMatchObject({ success: true, incremental: false });
+ expect(t.provider.calls).toHaveLength(2);
+ expect(t.provider.calls[1].user).toContain("obs 1");
+ expect(t.provider.calls[1].user).toContain("obs 5");
+ });
+
+ it("rebuilds a summary stored before watermarks existed, once", async () => {
+ const t = await setup("ses_legacy");
+ await t.addObs(1, 5, (i) => i);
+ await t.kv.set("summaries", "ses_legacy", {
+ sessionId: "ses_legacy",
+ project: "test-project",
+ createdAt: at(0),
+ title: "legacy",
+ narrative: "legacy narrative",
+ keyDecisions: [],
+ filesModified: [],
+ concepts: [],
+ observationCount: 5,
+ });
+
+ const first = await t.handler({ sessionId: "ses_legacy" });
+ const second = await t.handler({ sessionId: "ses_legacy" });
+
+ expect(first).toMatchObject({ success: true, incremental: false });
+ expect(second).toMatchObject({ success: true, unchanged: true });
+ expect(t.provider.calls).toHaveLength(1);
+ expect((await t.stored()).coveredThrough).toBe(at(5));
+ });
+});