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.
This commit is contained in:
@@ -4218,12 +4218,6 @@ impl<W: UiWriter> Agent<W> {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user