routing: fast-path voice when transcription not configured

This commit is contained in:
William Valentin
2026-02-13 18:35:04 -08:00
parent 7df0569a39
commit 944b2c916a
3 changed files with 184 additions and 9 deletions
+22 -8
View File
@@ -441,14 +441,28 @@ export function createMessageRouter(deps: {
}
: undefined;
if (audioConfig?.endpoint) {
for (const att of audioAttachments) {
const transcript = await transcribeAudio(att, audioConfig);
messageText = `[Voice message]: ${transcript}\n\n${messageText}`;
}
} else {
// No transcription endpoint configured — inform the user gracefully
messageText = '[Voice message received but audio transcription is not configured. Please configure the audio section in config.yaml to enable voice message support.]';
if (!audioConfig?.endpoint) {
// Without transcription, we cannot safely send audio to a non-audio-capable model.
// Fast-path a deterministic, user-friendly reply instead of invoking the agent loop.
await reply({
text:
[
'I received your voice message, but I cannot transcribe it yet because audio transcription is not configured.',
'',
'To enable voice messages, set `audio.enabled: true` and configure an `audio.provider` in `config.yaml` (OpenAI/Groq/custom Whisper-compatible `/v1/audio/transcriptions`).',
'',
'Workarounds:',
'1. Paste the transcription text.',
'2. Upload the audio file somewhere and send me a direct URL.',
].join('\n'),
replyTo: msg.id,
});
return;
}
for (const att of audioAttachments) {
const transcript = await transcribeAudio(att, audioConfig);
messageText = `[Voice message]: ${transcript}\n\n${messageText}`;
}
// Remove audio attachments so buildUserMessage doesn't create audio content parts
attachments = (msg.attachments ?? []).filter((a: Attachment) => !isSupportedAudio(a));