From 483be1fa984b86e4a1cb1b3f77ee8c4d8bc79a9f Mon Sep 17 00:00:00 2001 From: David Fernandez Date: Wed, 21 Jan 2026 13:51:10 -0600 Subject: [PATCH] fix(azure): handle None types in streaming tool aggregation Added guard clauses to check for None values in tool_call_chunk attributes (id, function.name, function.arguments) before concatenation. This prevents TypeError when Azure AI services return incomplete chunks during streaming. Fixes #7157 --- .../src/autogen_ext/models/azure/_azure_ai_client.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py b/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py index 16d56b57f956..8c8a5dbe7043 100644 --- a/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py +++ b/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py @@ -547,9 +547,13 @@ async def create_stream( if idx not in full_tool_calls: full_tool_calls[idx] = FunctionCall(id="", arguments="", name="") - full_tool_calls[idx].id += tool_call_chunk.id - full_tool_calls[idx].name += tool_call_chunk.function.name - full_tool_calls[idx].arguments += tool_call_chunk.function.arguments + if tool_call_chunk.id: + full_tool_calls[idx].id += tool_call_chunk.id + if tool_call_chunk.function: + if tool_call_chunk.function.name: + full_tool_calls[idx].name += tool_call_chunk.function.name + if tool_call_chunk.function.arguments: + full_tool_calls[idx].arguments += tool_call_chunk.function.arguments if chunk and chunk.usage: prompt_tokens = chunk.usage.prompt_tokens