From a41caf0a685fb2c66ca459e13df51df22fdad977 Mon Sep 17 00:00:00 2001 From: "luoxin.luo" Date: Mon, 2 Mar 2026 17:30:22 +0800 Subject: [PATCH] fix(ReActAgent): allow tool calls to reach acting phase for proper error feedback When model generates tool calls that don't exist in toolkit, the isFinished() method was prematurely terminating the ReAct loop, preventing the model from receiving error feedback. Now tool calls (even non-existent ones) proceed to the acting phase where ToolExecutor returns 'Tool not found' error. This allows the model to see the error in memory and self-correct in the next iteration. Simplified isFinished() to only check if there are tool calls, removing the toolkit existence check since error handling is already properly implemented in ToolExecutor.executeCore(). Change-Id: Ief1746255898fce715263b456d68f7c14d2a21d8 --- .../src/main/java/io/agentscope/core/ReActAgent.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java b/agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java index 2de490fa0..451b3d3eb 100644 --- a/agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java +++ b/agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java @@ -747,12 +747,9 @@ private boolean isFinished(Msg msg) { List toolCalls = msg.getContentBlocks(ToolUseBlock.class); // No tool calls - finished - if (toolCalls.isEmpty()) { - return true; - } - - // Has tool calls but none are in toolkit - finished - return toolCalls.stream().noneMatch(tc -> toolkit.getTool(tc.getName()) != null); + // If there are tool calls (even non-existent ones), continue to acting phase + // where ToolExecutor will return "Tool not found" error for the model to see + return toolCalls.isEmpty(); } /**