fix tool execute after hook boundary
This commit is contained in:
@@ -92,7 +92,6 @@ describe("createToolExecuteAfterHandler", () => {
|
|||||||
expect(output.title).toBe("stored title")
|
expect(output.title).toBe("stored title")
|
||||||
expect(output.metadata).toEqual({ sessionId: "ses_native", agent: "hephaestus" })
|
expect(output.metadata).toEqual({ sessionId: "ses_native", agent: "hephaestus" })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("#given native session linkage without model #when stored metadata exists #then required task metadata is preserved", async () => {
|
it("#given native session linkage without model #when stored metadata exists #then required task metadata is preserved", async () => {
|
||||||
// given
|
// given
|
||||||
const model = { providerID: "openai", modelID: "gpt-5.5" }
|
const model = { providerID: "openai", modelID: "gpt-5.5" }
|
||||||
@@ -122,4 +121,29 @@ describe("createToolExecuteAfterHandler", () => {
|
|||||||
expect(output.title).toBe("stored title")
|
expect(output.title).toBe("stored title")
|
||||||
expect(output.metadata).toEqual({ sessionId: "ses_native", agent: "hephaestus", model })
|
expect(output.metadata).toEqual({ sessionId: "ses_native", agent: "hephaestus", model })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("#given a non-extract hook throws #when tool.execute.after runs #then the handler absorbs the failure", async () => {
|
||||||
|
// given
|
||||||
|
const handler = createToolExecuteAfterHandler({
|
||||||
|
ctx: { directory: "/repo" } as never,
|
||||||
|
hooks: {
|
||||||
|
directoryAgentsInjector: {
|
||||||
|
"tool.execute.after": async () => {
|
||||||
|
throw new TypeError("output output is undefined")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as never,
|
||||||
|
})
|
||||||
|
|
||||||
|
const output = { title: "result", output: "read output", metadata: {} }
|
||||||
|
|
||||||
|
// when
|
||||||
|
await handler(
|
||||||
|
{ tool: "read", sessionID: "ses_parent", callID: "call_read" },
|
||||||
|
output
|
||||||
|
)
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(output).toEqual({ title: "result", output: "read output", metadata: {} })
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -182,6 +182,15 @@ export function createToolExecuteAfterHandler(args: {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await runToolExecuteAfterHooks()
|
try {
|
||||||
|
await runToolExecuteAfterHooks()
|
||||||
|
} catch (error) {
|
||||||
|
log("[tool-execute-after] Failed to process hooks", {
|
||||||
|
tool: input.tool,
|
||||||
|
sessionID: input.sessionID,
|
||||||
|
callID: input.callID ?? input.callId ?? input.call_id,
|
||||||
|
error,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user