Skip to content

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

fix: end Codex sessions on Stop hook (#495)

Nanamiabeec1d0b705
diff --git a/plugin/hooks/hooks.codex.json b/plugin/hooks/hooks.codex.json
index 73e43c66..3ce8463e 100644
--- a/plugin/hooks/hooks.codex.json
+++ b/plugin/hooks/hooks.codex.json
@@ -59,6 +59,10 @@
{
"type": "command",
"command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/stop.mjs"
+ },
+ {
+ "type": "command",
+ "command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/session-end.mjs"
}
]
}
diff --git a/test/codex-plugin.test.ts b/test/codex-plugin.test.ts
index bb380876..2b1fb3fa 100644
--- a/test/codex-plugin.test.ts
+++ b/test/codex-plugin.test.ts
@@ -91,6 +91,19 @@ describe("Codex plugin manifest (developers.openai.com/codex/plugins)", () => {
expect(existsSync(join(pluginRoot, rel)), `missing hook script: ${rel}`).toBe(true);
}
});
+
+ it("Stop hook summarizes and ends the session", () => {
+ type HookHandler = { type: string; command: string };
+ type HookEntry = { hooks: HookHandler[] };
+ const hooks = readJson<{ hooks: Record<string, HookEntry[]> }>(
+ join(pluginRoot, "hooks/hooks.codex.json"),
+ );
+ const stopCommands = hooks.hooks.Stop.flatMap((entry) =>
+ entry.hooks.map((handler) => handler.command),
+ );
+ expect(stopCommands).toContain("node ${CLAUDE_PLUGIN_ROOT}/scripts/stop.mjs");
+ expect(stopCommands).toContain("node ${CLAUDE_PLUGIN_ROOT}/scripts/session-end.mjs");
+ });
});
describe("Codex marketplace.json (.codex-plugin/marketplace.json at repo root)", () => {