@@ -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+ }
0 commit comments