test: cover messaging tool error fallback (#717)

This commit is contained in:
Peter Steinberger
2026-01-11 11:10:03 +00:00
parent 225b44ad3a
commit 580791088c

View File

@@ -635,6 +635,53 @@ describe("subscribeEmbeddedPiSession", () => {
expect(onBlockReply).not.toHaveBeenCalled();
});
it("does not suppress message_end replies when message tool reports error", () => {
let handler: ((evt: unknown) => void) | undefined;
const session: StubSession = {
subscribe: (fn) => {
handler = fn;
return () => {};
},
};
const onBlockReply = vi.fn();
subscribeEmbeddedPiSession({
session: session as unknown as Parameters<
typeof subscribeEmbeddedPiSession
>[0]["session"],
runId: "run",
onBlockReply,
blockReplyBreak: "message_end",
});
const messageText = "Please retry the send.";
handler?.({
type: "tool_execution_start",
toolName: "message",
toolCallId: "tool-message-err",
args: { action: "send", to: "+1555", message: messageText },
});
handler?.({
type: "tool_execution_end",
toolName: "message",
toolCallId: "tool-message-err",
isError: false,
result: { details: { status: "error" } },
});
const assistantMessage = {
role: "assistant",
content: [{ type: "text", text: messageText }],
} as AssistantMessage;
handler?.({ type: "message_end", message: assistantMessage });
expect(onBlockReply).toHaveBeenCalledTimes(1);
});
it("clears block reply state on message_start", () => {
let handler: ((evt: unknown) => void) | undefined;
const session: StubSession = {