fix(agents): error on failed tts tool synthesis

This commit is contained in:
lawrence3699
2026-04-17 14:47:11 +10:00
committed by Gustavo Madeira Santana
parent 0266cf4d10
commit af88310f31
2 changed files with 14 additions and 9 deletions

View File

@@ -41,4 +41,17 @@ describe("createTtsTool", () => {
});
expect(JSON.stringify(result.content)).not.toContain("MEDIA:");
});
it("throws when synthesis fails so the agent records a tool error", async () => {
textToSpeechSpy.mockResolvedValue({
success: false,
error: "TTS conversion failed: openai: not configured",
});
const tool = createTtsTool();
await expect(tool.execute("call-1", { text: "hello" })).rejects.toThrow(
"TTS conversion failed: openai: not configured",
);
});
});

View File

@@ -49,15 +49,7 @@ export function createTtsTool(opts?: {
};
}
return {
content: [
{
type: "text",
text: result.error ?? "TTS conversion failed",
},
],
details: { error: result.error },
};
throw new Error(result.error ?? "TTS conversion failed");
},
};
}