fix a looping error in iterations

This commit is contained in:
Dhanji Prasanna
2025-09-29 06:54:55 +10:00
parent 4e64555008
commit 39ef13e317

View File

@@ -1086,12 +1086,16 @@ The tool will execute immediately and you'll receive the result (success or erro
} }
if chunk.finished { if chunk.finished {
// Stream finished naturally without tool calls // Stream finished - check if we should continue or return
if !tool_executed {
// No tools were executed in this iteration, we're done
full_response.push_str(&current_response); full_response.push_str(&current_response);
println!(); println!();
let ttft = first_token_time.unwrap_or_else(|| stream_start.elapsed()); let ttft = first_token_time.unwrap_or_else(|| stream_start.elapsed());
return Ok((full_response, ttft)); return Ok((full_response, ttft));
} }
break; // Tool was executed, break to continue outer loop
}
} }
Err(e) => { Err(e) => {
error!("Streaming error: {}", e); error!("Streaming error: {}", e);