Skip to content

Commit a212a63

Browse files
danielholandagithub-actions[bot]
authored andcommitted
Improve Handling of MCP Tool Call Arguments (#3127)
* Handle empty MCP tool call arguments * Apply style fixes --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 6dd0164 commit a212a63

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/huggingface_hub/inference/_mcp/mcp_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,13 @@ async def process_single_turn_with_tools(
286286
for tool_call in delta.tool_calls:
287287
# Aggregate chunks into tool calls
288288
if tool_call.index not in final_tool_calls:
289-
if tool_call.function.arguments is None: # Corner case (depends on provider)
289+
if (
290+
tool_call.function.arguments is None or tool_call.function.arguments == "{}"
291+
): # Corner case (depends on provider)
290292
tool_call.function.arguments = ""
291293
final_tool_calls[tool_call.index] = tool_call
292294

293-
if tool_call.function.arguments:
295+
elif tool_call.function.arguments:
294296
final_tool_calls[tool_call.index].function.arguments += tool_call.function.arguments
295297

296298
# Optionally exit early if no tools in first chunks

0 commit comments

Comments
 (0)