From 39ef13e317a2082d6d2d262db366c82400020d0c Mon Sep 17 00:00:00 2001 From: Dhanji Prasanna Date: Mon, 29 Sep 2025 06:54:55 +1000 Subject: [PATCH] fix a looping error in iterations --- crates/g3-core/src/lib.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/g3-core/src/lib.rs b/crates/g3-core/src/lib.rs index 6106bcf..beabac2 100644 --- a/crates/g3-core/src/lib.rs +++ b/crates/g3-core/src/lib.rs @@ -1086,11 +1086,15 @@ The tool will execute immediately and you'll receive the result (success or erro } if chunk.finished { - // Stream finished naturally without tool calls - full_response.push_str(¤t_response); - println!(); - let ttft = first_token_time.unwrap_or_else(|| stream_start.elapsed()); - return Ok((full_response, ttft)); + // 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(¤t_response); + println!(); + let ttft = first_token_time.unwrap_or_else(|| stream_start.elapsed()); + return Ok((full_response, ttft)); + } + break; // Tool was executed, break to continue outer loop } } Err(e) => {