fix(ReActAgent): allow tool calls to reach acting phase for proper er…#850
fix(ReActAgent): allow tool calls to reach acting phase for proper er…#850LearningGp merged 3 commits intoagentscope-ai:mainfrom
Conversation
…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(). Change-Id: Ief1746255898fce715263b456d68f7c14d2a21d8
|
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the "ReActAgent"'s tool call processing to enhance error feedback mechanisms. By adjusting the "isFinished" method, the agent now allows all generated tool calls to reach the execution phase, ensuring that the model receives explicit "Tool not found" errors for invalid tool references. This change facilitates better self-correction capabilities for the agent. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
Fixes premature termination of the ReAct loop when the model emits tool calls that aren’t present in the toolkit, ensuring those calls still reach the acting phase so ToolExecutor can record a “Tool not found …” error in memory for model self-correction.
Changes:
- Simplified
ReActAgent#isFinished()to terminate only when there are no tool calls. - Removed the “tool must exist in toolkit” finish condition so unknown tool calls proceed to acting and produce error tool results.
There was a problem hiding this comment.
Code Review
This pull request addresses a bug in the ReActAgent where the agent would prematurely terminate if a model-generated tool call was for a tool not present in the toolkit. The change modifies the isFinished method to allow all tool calls, including those for non-existent tools, to proceed to the acting phase. This ensures that the ToolExecutor can generate a 'Tool not found' error, providing crucial feedback to the model for self-correction. The logic is now simpler and correctly delegates the error handling. The change is well-implemented and effectively resolves the issue.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…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.
mvn spotless:applymvn test)