fix(agent-loop): complete direct answers without a fake tool retry - #747
Open
imMamdouhaboammar wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the model returns a final text response with no tool calls,
agent_runner_loop()creates the internal pseudo-callno_tool.GenericAgentHandler.turn_end_callback()explicitly recognizes that pseudo-call as a direct answer, butBaseHandler.dispatch()did not. It fell through to the unknown-tool branch, producing未知工具 no_tooland forcing another turn.With
max_turns=1, a valid direct answer therefore ended asMAX_TURNS_EXCEEDEDinstead ofCURRENT_TASK_DONE.Fix
Teach
BaseHandler.dispatch()the existing internalno_toolsentinel and return a normalStepOutcomewith no next prompt. The loop then follows its existing completion path. Done hooks remain supported becauseCURRENT_TASK_DONEstill passes through the existing done-hook logic.Verification
TDD was performed on a separate validation branch:
31165930923failed on currentmain: the direct answer returnedMAX_TURNS_EXCEEDEDinstead ofCURRENT_TASK_DONE31165988879: compile, focused regression, andgit diff --checkmainas one clean commit containing only the production change and focused regression testScope
main