fix(compaction): restore context and todos before continue

This commit is contained in:
YeonGyu-Kim
2026-05-10 13:02:00 +09:00
parent 1ea4dfe215
commit dd29e9b96a
11 changed files with 601 additions and 16 deletions
+36
View File
@@ -88,6 +88,42 @@ describe("createToolExecuteBeforeHandler", () => {
expect(called).toBe(false)
})
test("runs compaction todo preserver before hook for todowrite", async () => {
//#given
let called = false
const ctx = {
client: {
session: {
messages: async () => ({ data: [] }),
},
},
}
const preservedTodos = [
{ content: "Preserved detailed task", status: "pending", priority: "high" },
]
const hooks = {
compactionTodoPreserver: {
"tool.execute.before": async (
input: { tool: string; sessionID: string; callID: string },
output: { args: Record<string, unknown> },
) => {
called = true
expect(input.tool).toBe("todowrite")
output.args.todos = preservedTodos
},
},
}
const handler = createToolExecuteBeforeHandler({ ctx, hooks })
const output = { args: { todos: [] } as Record<string, unknown> }
//#when
await handler({ tool: "todowrite", sessionID: "ses_compact", callID: "call_todo" }, output)
//#then
expect(called).toBe(true)
expect(output.args.todos).toBe(preservedTodos)
})
describe("task tool subagent_type normalization", () => {
const emptyHooks = {}
+1
View File
@@ -77,6 +77,7 @@ export function createToolExecuteBeforeHandler(args: {
await hooks.prometheusMdOnly?.["tool.execute.before"]?.(input, output)
await hooks.sisyphusJuniorNotepad?.["tool.execute.before"]?.(input, output)
await hooks.atlasHook?.["tool.execute.before"]?.(input, output)
await hooks.compactionTodoPreserver?.["tool.execute.before"]?.(input, output)
await hooks.teamToolGating?.["tool.execute.before"]?.(input, output)
const normalizedToolName = input.tool.toLowerCase()