From 7879445c4b02808b8374459a07e33286cd364b89 Mon Sep 17 00:00:00 2001 From: David Katz Date: Thu, 28 Aug 2025 10:56:16 -0400 Subject: [PATCH] Fast model falls back to regular (#4375) --- crates/goose/src/providers/base.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/goose/src/providers/base.rs b/crates/goose/src/providers/base.rs index bed31d5990..a71bc2113a 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