fix: cap consecutive empty LLM response retries to prevent infinite loop#225
Open
Kailigithub wants to merge 1 commit intolsdefine:mainfrom
Open
fix: cap consecutive empty LLM response retries to prevent infinite loop#225Kailigithub wants to merge 1 commit intolsdefine:mainfrom
Kailigithub wants to merge 1 commit intolsdefine:mainfrom
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.
Summary
Added a consecutive empty response counter to prevent the agent from entering an infinite retry loop when the LLM consistently returns empty content.
Closes #201
Changes
ga.py: Added_blank_streakcounter toGenericAgentHandler.__init__ga.py: Modifieddo_no_tool()to track consecutive blank responses and abort after 3 failuresDetails
Previously, when the LLM returned an empty response,
do_no_toolwould yield a warning and retry indefinitely (up to themax_turns=40outer loop limit). This caused excessive API calls, cost waste, and log flooding with "LLM returned an empty response. Retrying..." messages.The fix introduces a
_blank_streakcounter:next_prompt=Nonewhich signals the agent loop to exit gracefully