Fix: Resolve JSON malformation causing infinite loops and TypeError#1037
Open
gdeyoung wants to merge 1 commit intoagent0ai:mainfrom
Open
Fix: Resolve JSON malformation causing infinite loops and TypeError#1037gdeyoung wants to merge 1 commit intoagent0ai:mainfrom
gdeyoung wants to merge 1 commit intoagent0ai:mainfrom
Conversation
- Fixed rfind bug in extract_tools.py - proper nested brace tracking - Fixed escape handling for escaped quotes in JSON strings - Added HandledException class for graceful loop termination - Added consecutive_misformat counter (5 attempt limit) - Fixed tool_args TypeError - ensure dict before unpacking
Author
Additional Fix v1.2 - HandledException ShadowingIssue FoundA duplicate local class definition of
Root Cause
Fix AppliedRemoved the duplicate class definition (lines 349-355) in Files Changed
Verification
Added: 2026-02-14 |
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
Fixed multiple critical bugs causing JSON malformation, infinite loops, and TypeError crashes in Agent Zero.
Issues Fixed
1. JSON Object Extraction Bug (rfind)
File: python/helpers/extract_tools.py - Used rfind to find LAST closing brace instead of matching one
Fix: Proper nested brace tracking using depth counter
2. Escape Handling Logic Error
File: python/helpers/extract_tools.py - Escaped quotes not toggling in_string flag
Fix: Proper check for escaped quotes
3. No Loop Protection
File: agent.py - No protection against consecutive misformat errors
Fix: Added consecutive_misformat counter with 5-attempt limit + HandledException
4. TypeError: tool_args must be a mapping
File: agent.py - .get() returns string if key exists with string value
Fix: isinstance(tool_args, dict) validation