mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-22 19:47:15 +00:00
Merge 2c5a13bba7 into 6664fc7f38
This commit is contained in:
commit
f59c074e1a
1 changed files with 10 additions and 0 deletions
|
|
@ -13,6 +13,16 @@ def json_parse_dirty(json: str) -> dict[str, Any] | None:
|
|||
try:
|
||||
data = DirtyJson.parse_string(ext_json)
|
||||
if isinstance(data, dict):
|
||||
# Normalize: if it looks like a tool request, ensure required fields exist
|
||||
if "tool_name" in data or "tool" in data:
|
||||
# Normalize tool_name (some models use "tool" instead of "tool_name")
|
||||
if "tool" in data and "tool_name" not in data:
|
||||
data["tool_name"] = data.pop("tool")
|
||||
# Normalize tool_args — default to empty dict if missing or not a dict
|
||||
if "tool_args" not in data:
|
||||
data["tool_args"] = data.get("args", {})
|
||||
if not isinstance(data.get("tool_args"), dict):
|
||||
data["tool_args"] = {}
|
||||
return data
|
||||
except Exception:
|
||||
# If parsing fails, return None instead of crashing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue