Skip to content

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

fix(graph): auto-fire mem::graph-extract at session end (closes #210)

Rohit Ghumare91702963be7f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24964535..2cac3431 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## [Unreleased]
+### Fixed
+
+- **`mem::graph-extract` now auto-fires at session end.** When `GRAPH_EXTRACTION_ENABLED=true`, the function was registered and the REST endpoint was live, but no internal caller invoked it — the graph KV stayed empty unless users manually `POST`ed to `/agentmemory/graph/extract`. `event::session::stopped` now triggers it (fire-and-forget, idempotent via existing node/edge merge keys), so enabling the flag actually populates the graph. README pipeline diagram updated to show graph extraction at the Stop/SessionEnd phase rather than implying it runs per PostToolUse. (#210)
+
## [0.9.3] — 2026-04-24
Developer-experience patch. Every disabled feature flag is now visible in the viewer, the CLI, and REST error responses, so devs no longer hit empty tabs wondering whether the install is broken or just opt-in. Adds a `doctor` command that diagnoses the whole stack in one shot and a first-run hero in the viewer that points at the magical-moment `demo` command.
diff --git a/README.md b/README.md
index 36576244..b2602507 100644
--- a/README.md
+++ b/README.md
@@ -506,7 +506,12 @@ PostToolUse hook fires
-> Store raw observation
-> LLM compress -> structured facts + concepts + narrative
-> Vector embedding (6 providers + local)
- -> Index in BM25 + vector + knowledge graph
+ -> Index in BM25 + vector
+
+Stop / SessionEnd hook fires
+ -> Summarize session
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
SessionStart hook fires
-> Load project profile (top concepts, files, patterns)
diff --git a/src/triggers/events.ts b/src/triggers/events.ts
index 418ccc88..ce1a282c 100644
--- a/src/triggers/events.ts
+++ b/src/triggers/events.ts
@@ -1,8 +1,9 @@
import { TriggerAction, type ISdk } from "iii-sdk";
-import type { HookPayload, Session } from "../types.js";
+import type { CompressedObservation, HookPayload, Session } from "../types.js";
import { KV, STREAM } from "../state/schema.js";
import { StateKV } from "../state/kv.js";
import { isReflectEnabled } from "../functions/slots.js";
+import { isGraphExtractionEnabled } from "../config.js";
import { logger } from "../logger.js";
export function registerEventTriggers(sdk: ISdk, kv: StateKV): void {
@@ -55,6 +56,22 @@ export function registerEventTriggers(sdk: ISdk, kv: StateKV): void {
});
}
}
+ if (isGraphExtractionEnabled()) {
+ try {
+ const observations = await kv.list<CompressedObservation>(
+ KV.observations(data.sessionId),
+ );
+ const compressed = observations.filter((o) => o.title);
+ if (compressed.length > 0) {
+ sdk.triggerVoid("mem::graph-extract", { observations: compressed });
+ }
+ } catch (err) {
+ logger.warn("graph-extract triggerVoid failed", {
+ sessionId: data.sessionId,
+ error: err instanceof Error ? err.message : String(err),
+ });
+ }
+ }
return summary;
});
sdk.registerTrigger({