fix: let agents fix their own tool call format instead of erroring
Nicolas Leão committed
Mar 29, 2026 at 11:03 UTC
bd5eb7c61c6ae5f559fa1a8675c66138598d4487
1 file changed
+4
-2
agent.py
+4
-2
@@ -848,8 +848,10 @@ class Agent:
848
# search for tool usage requests in agent message
849
tool_request = extract_tools.json_parse_dirty(msg)
850
851
- # basic validation + extensions
852
- await self.validate_tool_request(tool_request)
851
+ # Only validate when extraction produced an object; None means no JSON tool
852
+ # block was found — the misformat warning path below handles that.
853
+ if tool_request is not None:
854
+ await self.validate_tool_request(tool_request)
855
856
if tool_request is not None:
857
raw_tool_name = tool_request.get("tool_name", tool_request.get("tool","")) # Get the raw tool name