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) {