Skip to content

fix: normalize tool_args before validation in process_tools#1513

Open
wgnrai wants to merge 1 commit intoagent0ai:mainfrom
wgnrai:fix/tool-args-validation
Open

fix: normalize tool_args before validation in process_tools#1513
wgnrai wants to merge 1 commit intoagent0ai:mainfrom
wgnrai:fix/tool-args-validation

Conversation

@wgnrai
Copy link
Copy Markdown

@wgnrai wgnrai commented Apr 14, 2026

Fix for #1512

Problem

validate_tool_request() crashes with ValueError when an LLM outputs "args" instead of "tool_args" in the tool request JSON.

Solution

Add normalization before calling validate_tool_request():

  • Map "args""tool_args" if "tool_args" is missing
  • Default "tool_args" to empty dict if not a dict type

Changes

  • agent.py: Added 4-line normalization block before validate_tool_request() call in process_tools()

Testing

  • Handles {"tool_name": "x", "args": {}} → normalizes to {"tool_name": "x", "tool_args": {}}
  • Correctly formatted requests pass unchanged
  • Non-dict values defaulted to {}

Closes #1512

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.

Bug: ValueError crash when LLM outputs "args" instead of "tool_args"

1 participant