Skip to content

Commit ee9a22a

Browse files
authored
Update _assistant_agent.py
## Description When using Claude models (or other LLM providers) with tool calling, the `tool_call.arguments` field may be an empty string `""` instead of `"{}"` for tools that don't require parameters. This causes a `JSONDecodeError[ in ](file://core/mt_llm_client.py#90#24)AssistantAgent._execute_tool_call` method, even though the tool call is valid and should be executed with empty arguments. ## Current Behavior ```python # In _assistant_agent.py line 1547 arguments = json.loads(tool_call.arguments) # Raises JSONDecodeError for "" ``` When `tool_call.arguments = ""`, this raises:
1 parent 13e144e commit ee9a22a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,11 @@ async def _execute_tool_call(
15441544
"""Execute a single tool call and return the result."""
15451545
# Load the arguments from the tool call.
15461546
try:
1547-
arguments = json.loads(tool_call.arguments)
1547+
# Handle empty string as empty dict to support tools with no parameters
1548+
if not tool_call.arguments or tool_call.arguments.strip() == "":
1549+
arguments = {}
1550+
else:
1551+
arguments = json.loads(tool_call.arguments)
15481552
except json.JSONDecodeError as e:
15491553
return (
15501554
tool_call,

0 commit comments

Comments
 (0)