Skip to content

fix(agent-loop): complete direct answers without a fake tool retry - #747

Open
imMamdouhaboammar wants to merge 1 commit into
lsdefine:mainfrom
imMamdouhaboammar:fix/agent-loop-no-tool-completion-upstream
Open

fix(agent-loop): complete direct answers without a fake tool retry#747
imMamdouhaboammar wants to merge 1 commit into
lsdefine:mainfrom
imMamdouhaboammar:fix/agent-loop-no-tool-completion-upstream

Conversation

@imMamdouhaboammar

Copy link
Copy Markdown

Problem

When the model returns a final text response with no tool calls, agent_runner_loop() creates the internal pseudo-call no_tool. GenericAgentHandler.turn_end_callback() explicitly recognizes that pseudo-call as a direct answer, but BaseHandler.dispatch() did not. It fell through to the unknown-tool branch, producing 未知工具 no_tool and forcing another turn.

With max_turns=1, a valid direct answer therefore ended as MAX_TURNS_EXCEEDED instead of CURRENT_TASK_DONE.

Fix

Teach BaseHandler.dispatch() the existing internal no_tool sentinel and return a normal StepOutcome with no next prompt. The loop then follows its existing completion path. Done hooks remain supported because CURRENT_TASK_DONE still passes through the existing done-hook logic.

Verification

TDD was performed on a separate validation branch:

  1. Regression-only GitHub Actions run 31165930923 failed on current main: the direct answer returned MAX_TURNS_EXCEEDED instead of CURRENT_TASK_DONE
  2. The one-line dispatch fix passed run 31165988879: compile, focused regression, and git diff --check
  3. The final contribution branch was rebuilt directly from current main as one clean commit containing only the production change and focused regression test

Scope

  • 1 core production file modified
  • 1 focused regression-test file added
  • 1 clean commit on top of current main
  • no dependency or configuration changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant