Skip to content

Commit 2b21847

Browse files
feat: add fallback to Sonnet 3.5 before trying Gemini Flash 2.0
This commit adds an intermediate fallback step to Claude Sonnet 3.5 when Sonnet 3.7 fails, before attempting to use Gemini Flash 2.0. It also updates the default LLM to Sonnet 3.7.
1 parent 29c43e9 commit 2b21847

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

sidecar/src/agentic/tool/session/tool_use_agent.rs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,8 +1421,36 @@ You accomplish a given task iteratively, breaking it down into clear steps and w
14211421
}
14221422
}
14231423

1424-
// If original LLM (Sonnet) failed, try with gemini-flash-2.0
1425-
if llm_properties.llm() == &LLMType::ClaudeSonnet {
1424+
// If original LLM (Sonnet3.7) failed, try with sonnet3.5 first
1425+
if llm_properties.llm() == &LLMType::ClaudeSonnet37 {
1426+
println!("sonnet37_failed::failing_back_to_sonnet35");
1427+
let sonnet35_properties = llm_properties.clone().set_llm(LLMType::ClaudeSonnet);
1428+
if let Ok(Some(result)) = self
1429+
.try_with_llm(
1430+
sonnet35_properties,
1431+
cancellation_token.clone(),
1432+
root_request_id.clone(),
1433+
ui_sender.clone(),
1434+
exchange_id,
1435+
final_messages.to_vec(),
1436+
None,
1437+
)
1438+
.await
1439+
{
1440+
if matches!(
1441+
result,
1442+
ToolUseAgentOutput {
1443+
r#type: ToolUseAgentOutputType::Success(_),
1444+
usage_statistics: _,
1445+
}
1446+
) {
1447+
return Ok(result);
1448+
}
1449+
}
1450+
}
1451+
1452+
// If sonnet3.5 failed or if using a different model, try with gemini-flash-2.0
1453+
if llm_properties.llm() == &LLMType::ClaudeSonnet37 || llm_properties.llm() == &LLMType::ClaudeSonnet {
14261454
println!("sonnet_failed::failing_back_to_gemini-2.0-flash");
14271455
let gemini_pro_properties = llm_properties.clone().set_llm(LLMType::Gemini2_0Flash);
14281456
if let Ok(Some(result)) = self
@@ -2870,4 +2898,4 @@ To get the current time in Timbuktu, Mali, I'll need to use the mcp::time::get_c
28702898
let tool_use_possible = tool_use_generator.tool_input_partial;
28712899
assert!(tool_use_possible.is_some());
28722900
}
2873-
}
2901+
}

sidecar/src/bin/agent_bin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
141141
let llm_model = if let Some(model_name) = args.model_name {
142142
LLMType::Custom(model_name)
143143
} else {
144-
LLMType::ClaudeSonnet
144+
LLMType::ClaudeSonnet37
145145
};
146146

147147
let llm_provider = LLMProperties::new(

0 commit comments

Comments
 (0)