-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
What happened?
AzureAIChatCompletionClient streaming tool_calls can include None fields, causing TypeError
Which packages was the bug in? autogen-ext (the error is in autogen_ext.models.azure._azure_ai_client)
To Reproduce
Use AzureAIChatCompletionClient with GitHub Models (Azure AI Foundry) endpoint https://models.inference.ai.azure.com.
Enable streaming (model_client_stream=True) and allow tool calls.
Ask a tool-eligible prompt (e.g., “What is the weather in New York?”) with a tool registered.
Expected
Streaming completes and tool-call chunks are aggregated without error.
Actual
TypeError in streaming tool-call aggregation when a chunk has id (or function name/arguments) set to None:
TypeError: can only concatenate str (not "NoneType") to str
at autogen_ext/models/azure/_azure_ai_client.py line ~550
Root cause
tool_call_chunk.id, tool_call_chunk.function.name, or tool_call_chunk.function.arguments can be None in streamed deltas. The Azure client concatenates them unconditionally.
Proposed fix
Add None guards before concatenation in _azure_ai_client.py (streaming tool-call aggregation loop), similar to the OpenAI client’s handling.
Minimal patch (conceptual)
if tool_call_chunk.id is not None:
full_tool_calls[idx].id += tool_call_chunk.id
if tool_call_chunk.function is not None:
if tool_call_chunk.function.name is not None:
full_tool_calls[idx].name += tool_call_chunk.function.name
if tool_call_chunk.function.arguments is not None:
full_tool_calls[idx].arguments += tool_call_chunk.function.arguments
Environment
Additional context
Windows 11
Python 3.13
autogen-agentchat + autogen-ext (versions from pip; can provide exact versions if needed)
Using GitHub Models via Azure AI Foundry endpoint
Which packages was the bug in?
Python Core (autogen-core), Python Extensions (autogen-ext)
AutoGen library version.
Python dev (main branch)
Other library version.
autogen-ext==0.7.5 autogen-agentchat==0.7.5 autogen-core==0.7.5
Model used
gpt-4.1-mini
Model provider
Azure AI Foundary (Azure AI Studio)
Other model provider
No response
Python version
3.13
.NET version
None
Operating system
Windows