Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions plugin/scripts/stop.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ async function main() {
body: JSON.stringify({ sessionId }),
signal: AbortSignal.timeout(12e4)
}).catch(() => {});
fetch(`${REST_URL}/agentmemory/session/end`, {
method: "POST",
headers: authHeaders(),
body: JSON.stringify({ sessionId }),
signal: AbortSignal.timeout(5e3)
}).catch(() => {});
setTimeout(() => process.exit(0), 1500).unref();
}
main();
Expand Down
17 changes: 11 additions & 6 deletions src/hooks/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ async function main() {
signal: AbortSignal.timeout(120000),
}).catch(() => {});

fetch(`${REST_URL}/agentmemory/session/end`, {
method: "POST",
headers: authHeaders(),
body: JSON.stringify({ sessionId }),
signal: AbortSignal.timeout(5000),
}).catch(() => {});
// TODO(codex-session-end): Codex does not fire a separate SessionEnd event,
// so its Stop hook was the only signal to close the session lifecycle.
// We removed the /session/end call here because Claude Code (and other agents)
// fire Stop after every assistant turn, causing premature session completion.
// Re-add once a reliable Codex identifier is available in the hook payload.
// fetch(`${REST_URL}/agentmemory/session/end`, {
// method: "POST",
// headers: authHeaders(),
// body: JSON.stringify({ sessionId }),
// signal: AbortSignal.timeout(5000),
// }).catch(() => {});

setTimeout(() => process.exit(0), 1500).unref();
}
Expand Down
12 changes: 12 additions & 0 deletions test/copilot-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,16 @@ describe("Copilot hook scripts", () => {
},
});
});

it("stop calls /summarize but not /session/end", async () => {
const result = await runHook("scripts/stop.mjs", {
sessionId: "copilot-session",
cwd: "C:\\repo",
});

expect(result.stdout).toBe("");
const paths = result.requests.map((r) => r.path);
expect(paths).toContain("/agentmemory/summarize");
expect(paths).not.toContain("/agentmemory/session/end");
});
});