fix: accept 'args' alias and null value in validate_tool_request#1491
Open
GratefulDave wants to merge 1 commit intoagent0ai:mainfrom
Open
fix: accept 'args' alias and null value in validate_tool_request#1491GratefulDave wants to merge 1 commit intoagent0ai:mainfrom
GratefulDave wants to merge 1 commit intoagent0ai:mainfrom
Conversation
Some LLMs intermittently emit 'args' instead of 'tool_args'. The
downstream process_tools() already handles this alias via .get('tool_args',
.get('args', {})), but validate_tool_request() only accepted 'tool_args',
causing a ValueError before process_tools could normalize the response.
Also tolerate a missing/null tool_args value since process_tools already
defaults it to {}. Still raises if the value is present but not a dict.
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
validate_tool_requestraises aValueErrorintermittently when the LLM emits"args"instead of"tool_args"in its JSON response:The bug is a mismatch between validation and processing:
process_toolsalready handles the"args"alias:.get("tool_args", .get("args", {}))validate_tool_requestonly accepted"tool_args"— rejecting"args"beforeprocess_toolscould normalize itAlso, a
null/ missingtool_argsvalue raised erroneously, even thoughprocess_toolsalready defaults it to{}.Fix
"args"as an alias for"tool_args"(matches whatprocess_toolsalready does)null/ missing value (downstream already defaults to{})Impact
ValueErrorcrashes when models use non-standard field names