Bug Report
Problem
In agent.py, process_tools() calls validate_tool_request(tool_request) without normalizing the dictionary first. Some LLMs output "args" instead of "tool_args".
This causes a crash:
ValueError: Tool request must have a tool_args (type dictionary) field
Location
agent.py line ~877-878:
if tool_request is not None:
await self.validate_tool_request(tool_request)
Reproduction
- Use an LLM that outputs
"args" key instead of "tool_args"
- Tool request JSON:
{"tool_name": "some_tool", "args": {...}}
validate_tool_request() raises ValueError
Proposed Fix
Add normalization before validation:
if tool_request is not None:
# Normalize: map "args" -> "tool_args", default to empty dict
if "tool_args" not in tool_request:
tool_request["tool_args"] = tool_request.get("args", {})
if not isinstance(tool_request["tool_args"], dict):
tool_request["tool_args"] = {}
await self.validate_tool_request(tool_request)
Consistent with downstream handling at line ~882:
tool_args = tool_request.get("tool_args", tool_request.get("args", {}))
Impact
- Prevents crashes with LLMs using non-standard key naming
- No behavior change for correctly formatted requests
- Defensive programming for edge cases
PR ready with this fix.
Bug Report
Problem
In
agent.py,process_tools()callsvalidate_tool_request(tool_request)without normalizing the dictionary first. Some LLMs output"args"instead of"tool_args".This causes a crash:
Location
agent.pyline ~877-878:Reproduction
"args"key instead of"tool_args"{"tool_name": "some_tool", "args": {...}}validate_tool_request()raisesValueErrorProposed Fix
Add normalization before validation:
Consistent with downstream handling at line ~882:
Impact
PR ready with this fix.