Skip to content

Commit 63f7e92

Browse files
luoxinerLearningGp
andauthored
fix(ReActAgent): allow tool calls to reach acting phase for proper error feedback(#850)
…ror 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(). ## AgentScope-Java Version [The version of AgentScope-Java you are working on, e.g. 1.0.9, check your pom.xml dependency version or run `mvn dependency:tree | grep agentscope-parent:pom`(only mac/linux)] ## Description [Please describe the background, purpose, changes made, and how to test this PR] ## Checklist Please check the following items before code is ready to be reviewed. - [x] Code has been formatted with `mvn spotless:apply` - [x] All tests are passing (`mvn test`) - [x] Javadoc comments are complete and follow project conventions - [x] Related documentation has been updated (e.g. links, examples, etc.) - [x] Code is ready for review Co-authored-by: LearningGp <learninggp4.74@gmail.com>
1 parent 84f1354 commit 63f7e92

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,9 @@ private boolean isFinished(Msg msg) {
750750
List<ToolUseBlock> toolCalls = msg.getContentBlocks(ToolUseBlock.class);
751751

752752
// No tool calls - finished
753-
if (toolCalls.isEmpty()) {
754-
return true;
755-
}
756-
757-
// Has tool calls but none are in toolkit - finished
758-
return toolCalls.stream().noneMatch(tc -> toolkit.getTool(tc.getName()) != null);
753+
// If there are tool calls (even non-existent ones), continue to acting phase
754+
// where ToolExecutor will return "Tool not found" error for the model to see
755+
return toolCalls.isEmpty();
759756
}
760757

761758
/**

0 commit comments

Comments
 (0)