Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/agent/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2491,7 +2491,15 @@ async fn transcribe_audio_attachment(
}

let (provider_id, model_name) = match deps.llm_manager.resolve_model(voice_model) {
Ok(parts) => parts,
Ok(parts) => {
tracing::debug!(
provider = %parts.0,
model = %parts.1,
voice_config = %voice_model,
"resolved voice model for transcription"
);
parts
}
Err(error) => {
tracing::warn!(%error, model = %voice_model, "invalid voice model route");
return UserContent::text(format!(
Expand All @@ -2502,7 +2510,15 @@ async fn transcribe_audio_attachment(
};

let provider = match deps.llm_manager.get_provider(&provider_id) {
Ok(provider) => provider,
Ok(provider) => {
tracing::debug!(
provider = %provider_id,
base_url = %provider.base_url,
api_type = ?provider.api_type,
"got provider for voice transcription"
);
provider
}
Err(error) => {
tracing::warn!(%error, provider = %provider_id, "voice provider not configured");
return UserContent::text(format!(
Expand All @@ -2527,6 +2543,11 @@ async fn transcribe_audio_attachment(
"{}/v1/chat/completions",
provider.base_url.trim_end_matches('/')
);
tracing::debug!(
endpoint = %endpoint,
model = %model_name,
"sending voice transcription request"
);
let body = serde_json::json!({
"model": model_name,
"messages": [{
Expand Down
12 changes: 10 additions & 2 deletions src/llm/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,20 @@ impl LlmManager {
}

/// Resolve a model name to provider and model components.
/// Format: "provider/model-name" or just "model-name" (defaults to anthropic).
/// Format: "provider/model-name" or just "model-name" (defaults to openai for voice models).
pub fn resolve_model(&self, model_name: &str) -> Result<(String, String)> {
if let Some((provider, model)) = model_name.split_once('/') {
tracing::debug!(provider = %provider, model = %model, "resolved model with explicit provider");
Ok((provider.to_string(), model.to_string()))
} else {
Ok(("anthropic".into(), model_name.into()))
// Default to openai for voice models (most common for Whisper/vision)
// rather than anthropic, since anthropic doesn't support input_audio
tracing::debug!(
model = %model_name,
"no provider prefix specified in model name, defaulting to 'openai'. \
Specify as 'provider/model' (e.g., 'openai/whisper-1') to use a different provider."
);
Comment on lines +292 to +304
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

"for voice models" qualifier in doc and inline comment is inaccurate.

resolve_model is general-purpose — it resolves model names for all usages (chat, vision, voice, etc.), not just voice. The "for voice models" qualifier in both the doc comment (Line 292) and the inline comment (Line 298) will mislead developers maintaining non-voice code paths that hit this fallback.

📝 Proposed fix
-    /// Format: "provider/model-name" or just "model-name" (defaults to openai for voice models).
+    /// Format: "provider/model-name" or just "model-name" (defaults to openai when no provider prefix is given).
     pub fn resolve_model(&self, model_name: &str) -> Result<(String, String)> {
         if let Some((provider, model)) = model_name.split_once('/') {
             tracing::debug!(provider = %provider, model = %model, "resolved model with explicit provider");
             Ok((provider.to_string(), model.to_string()))
         } else {
-            // Default to openai for voice models (most common for Whisper/vision)
-            // rather than anthropic, since anthropic doesn't support input_audio
+            // Default to openai for all unprefixed model names.
+            // Previously defaulted to anthropic, which lacks input_audio support for voice.
             tracing::debug!(
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/llm/manager.rs` around lines 292 - 304, The doc and inline comments
incorrectly qualify the default behavior as "for voice models"; update the
documentation and the comment inside the resolve_model function to state that
the function is general-purpose and that when no provider prefix is specified it
defaults to "openai" (used as the fallback provider for cases like
Whisper/vision/chat), e.g., change the doc comment on resolve_model and the
inline comment that currently mentions "for voice models" to a neutral wording
such as "Default to 'openai' when no provider is specified" and keep the
existing tracing::debug message but remove the "for voice models" phrase so
maintainers of chat/vision code paths are not misled.

Ok(("openai".into(), model_name.into()))
}
}

Expand Down