Skip to content

Commit 04dbb85

Browse files
alpha-xoneLockeysama
authored andcommitted
Prevent json from loading dict (agno-agi#3077)
Sometimes the `tool_call_arguments` is already a dict. Pass it thru directly. ## Summary Sometime `tool_call_arguments` is already a `dict` - pass it thru directly to prevent json to load it again. ## Type of change - [x] Bug fix --- ## Checklist - [x] Code complies with style guidelines - [x] Ran format/validation scripts (`./scripts/format.sh` and `./scripts/validate.sh`) - [x] Self-review completed - [ ] Documentation updated (comments, docstrings) - [ ] Examples and guides: Relevant cookbook examples have been included or updated (if applicable) - [x] Tested in clean environment - [ ] Tests added/updated (if applicable)
1 parent 8e96ee6 commit 04dbb85

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libs/agno/agno/models/message.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,12 @@ def log(self, metrics: bool = True, level: Optional[str] = None):
330330
tool_call_arguments = tool_call.get("function", {}).get("arguments")
331331
if tool_call_arguments:
332332
try:
333-
arguments = ", ".join(f"{k}: {v}" for k, v in json.loads(tool_call_arguments).items())
333+
tool_call_args: dict = (
334+
tool_call_arguments
335+
if isinstance(tool_call_arguments, dict)
336+
else json.loads(tool_call_arguments)
337+
)
338+
arguments = ", ".join(f"{k}: {v}" for k, v in tool_call_args.items())
334339
tool_calls_list.append(f" Arguments: '{arguments}'")
335340
except json.JSONDecodeError:
336341
tool_calls_list.append(" Arguments: 'Invalid JSON format'")

0 commit comments

Comments
 (0)