fix(reminder-hooks): preserve suppression state across compaction

This commit is contained in:
Disaster-Terminator
2026-04-18 09:40:09 +08:00
committed by YeonGyu-Kim
parent ae7ff3bb7e
commit 3db1da1e5b
4 changed files with 108 additions and 16 deletions
@@ -127,12 +127,6 @@ export function createCategorySkillReminderHook(
}
}
if (event.type === "session.compacted") {
const sessionID = resolveSessionEventID(props)
if (sessionID) {
sessionStates.delete(sessionID)
}
}
}
return {
@@ -282,7 +282,7 @@ describe("category-skill-reminder hook", () => {
clearSessionAgent(sessionID)
})
test("should reset state on session.compacted event", async () => {
test("should preserve suppression state on session.compacted event", async () => {
// given - sisyphus agent with reminder already shown
const hook = createHook()
const sessionID = "compact-session"
@@ -302,8 +302,30 @@ describe("category-skill-reminder hook", () => {
await hook["tool.execute.after"]({ tool: "edit", sessionID, callID: "5" }, output2)
await hook["tool.execute.after"]({ tool: "edit", sessionID, callID: "6" }, output2)
// then - reminder should be shown again (state was reset)
expect(output2.output).toContain("[Category+Skill Reminder]")
// then - reminder should NOT be shown again (state remains suppressed)
expect(output2.output).not.toContain("[Category+Skill Reminder]")
clearSessionAgent(sessionID)
})
test("should preserve partial tool-call count across session.compacted", async () => {
// given - sisyphus agent with 2 delegatable tool calls
const hook = createHook()
const sessionID = "compact-partial-count-session"
updateSessionAgent(sessionID, "Sisyphus")
const output = { title: "", output: "result", metadata: {} }
await hook["tool.execute.after"]({ tool: "edit", sessionID, callID: "1" }, output)
await hook["tool.execute.after"]({ tool: "edit", sessionID, callID: "2" }, output)
expect(output.output).not.toContain("[Category+Skill Reminder]")
// when - the session compacts before the third tool call
await hook.event({ event: { type: "session.compacted", properties: { sessionID } } })
await hook["tool.execute.after"]({ tool: "edit", sessionID, callID: "3" }, output)
// then - the third call should still trigger the reminder
expect(output.output).toContain("[Category+Skill Reminder]")
clearSessionAgent(sessionID)
})