diff --git a/crates/goose/src/providers/base.rs b/crates/goose/src/providers/base.rs index bed31d59909c..a71bc2113a29 100644 --- a/crates/goose/src/providers/base.rs +++ b/crates/goose/src/providers/base.rs @@ -348,8 +348,27 @@ pub trait Provider: Send + Sync { ) -> Result<(Message, ProviderUsage), ProviderError> { let model_config = self.get_model_config(); let fast_config = model_config.use_fast_model(); - self.complete_with_model(&fast_config, system, messages, tools) + + match self + .complete_with_model(&fast_config, system, messages, tools) .await + { + Ok(result) => Ok(result), + Err(e) => { + if fast_config.model_name != model_config.model_name { + tracing::warn!( + "Fast model {} failed with error: {}. Falling back to regular model {}", + fast_config.model_name, + e, + model_config.model_name + ); + self.complete_with_model(&model_config, system, messages, tools) + .await + } else { + Err(e) + } + } + } } /// Get the model config from the provider