From fdc003bb3fe7b08dd230ef28c12461a334b197d3 Mon Sep 17 00:00:00 2001 From: Hiago Silva <97215740+Huntterxx@users.noreply.github.com> Date: Mon, 16 Mar 2026 08:44:00 -0300 Subject: [PATCH] fix(tts): fail fast when no delivery channel is bound Prevents TTS tool from hanging indefinitely in isolated cron sessions where no channel is bound for audio delivery. Part of #43483 --- src/agents/tools/tts-tool.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/agents/tools/tts-tool.ts b/src/agents/tools/tts-tool.ts index 03ed3cd9a04..7b8150c5230 100644 --- a/src/agents/tools/tts-tool.ts +++ b/src/agents/tools/tts-tool.ts @@ -27,11 +27,25 @@ export function createTtsTool(opts?: { const params = args as Record; const text = readStringParam(params, "text", { required: true }); const channel = readStringParam(params, "channel"); + const resolvedChannel = channel ?? opts?.agentChannel; const cfg = opts?.config ?? loadConfig(); + + if (!resolvedChannel) { + return { + content: [ + { + type: "text", + text: "TTS requires a bound channel for audio delivery. Use sessionTarget: \"main\" or provide a channel parameter.", + }, + ], + details: { error: "no_channel" }, + }; + } + const result = await textToSpeech({ text, cfg, - channel: channel ?? opts?.agentChannel, + channel: resolvedChannel, }); if (result.success && result.audioPath) {