From 58cbf3431a43abb9eba03c65ba38f42f4059153d Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Mon, 22 Dec 2025 16:24:11 +1100 Subject: [PATCH] Fix auto-continue bug: don't mark tool calls consumed prematurely The bug: When the LLM emitted multiple tool calls in one response (e.g., str_replace followed by shell), only the first tool was executed. The remaining tools were lost because mark_tool_calls_consumed() was called BEFORE processing, marking ALL tools as consumed even when only ONE was being processed. This caused has_unexecuted_tool_call() to return false after executing the first tool, so the parser was reset and the remaining tool calls were discarded. The auto-continue logic never triggered because it thought all tools had been handled. The fix: Remove the premature mark_tool_calls_consumed() call. The existing logic at line 4696-4699 already handles marking tools as consumed AFTER execution, and correctly checks for remaining unexecuted tools before deciding whether to reset the parser. --- crates/g3-core/src/lib.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/crates/g3-core/src/lib.rs b/crates/g3-core/src/lib.rs index 0717744..05c39b7 100644 --- a/crates/g3-core/src/lib.rs +++ b/crates/g3-core/src/lib.rs @@ -4218,12 +4218,6 @@ impl Agent { completed_tools.into_iter().take(1).collect() }; - // Mark tool calls as consumed so has_unexecuted_tool_call() won't - // return true for tools we're about to execute - if !tools_to_process.is_empty() { - parser.mark_tool_calls_consumed(); - } - // Helper function to check if two tool calls are duplicates let are_duplicates = |tc1: &ToolCall, tc2: &ToolCall| -> bool { tc1.tool == tc2.tool && tc1.args == tc2.args