From ce09fe48bf88273edc6f5b1ffea2b7771cfddff2 Mon Sep 17 00:00:00 2001 From: Kanchi Shimono <17161397+KanchiShimono@users.noreply.github.com> Date: Sun, 25 May 2025 16:30:35 +0900 Subject: [PATCH 1/3] Fix handling of Bing Grounding Tool results in streaming mode --- .../agents/azure_ai/agent_content_generation.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/python/semantic_kernel/agents/azure_ai/agent_content_generation.py b/python/semantic_kernel/agents/azure_ai/agent_content_generation.py index e108928ef012..523f7680d446 100644 --- a/python/semantic_kernel/agents/azure_ai/agent_content_generation.py +++ b/python/semantic_kernel/agents/azure_ai/agent_content_generation.py @@ -398,14 +398,13 @@ def generate_streaming_bing_grounding_content( for index, tool in enumerate(step_details.tool_calls): if tool.type == "bing_grounding": - bing_tool = cast(RunStepBingGroundingToolCall, tool) - arguments = getattr(bing_tool, "bing_grounding", None) + arguments = tool.get("bing_grounding", None) items.append( FunctionCallContent( - id=bing_tool.id, + id=tool.id, index=index, - name=bing_tool.type, - function_name=bing_tool.type, + name=tool.type, + function_name=tool.type, arguments=arguments, ) ) From 2631b2349c8181b00668027f0c495820a4377b02 Mon Sep 17 00:00:00 2001 From: Kanchi Shimono <17161397+KanchiShimono@users.noreply.github.com> Date: Sun, 25 May 2025 16:34:43 +0900 Subject: [PATCH 2/3] Yield `ChatMessageContent` of Bing Grounding Tool call results --- python/semantic_kernel/agents/azure_ai/agent_thread_actions.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/semantic_kernel/agents/azure_ai/agent_thread_actions.py b/python/semantic_kernel/agents/azure_ai/agent_thread_actions.py index 7fdcce98ef82..f02350b42759 100644 --- a/python/semantic_kernel/agents/azure_ai/agent_thread_actions.py +++ b/python/semantic_kernel/agents/azure_ai/agent_thread_actions.py @@ -290,6 +290,7 @@ def sort_key(step: RunStep): content = generate_bing_grounding_content( agent_name=agent.name, bing_tool_call=bing_call ) + is_visible = True case AgentsNamedToolChoiceType.AZURE_AI_SEARCH: logger.debug( f"Entering tool_calls (azure_ai_search) for run [{run.id}], agent " @@ -495,6 +496,7 @@ async def _process_stream_events( content = generate_streaming_bing_grounding_content( agent_name=agent.name, step_details=details ) + content_is_visible = True case AgentsNamedToolChoiceType.AZURE_AI_SEARCH: content = generate_streaming_azure_ai_search_content( agent_name=agent.name, step_details=details From 57fa33cd97a466e2631958424740308be5d81153 Mon Sep 17 00:00:00 2001 From: Kanchi Shimono <17161397+KanchiShimono@users.noreply.github.com> Date: Mon, 26 May 2025 16:20:22 +0900 Subject: [PATCH 3/3] Fix to prevent yielding unnecessary `FunctionCallContent` This reverts commit 2631b2349c8181b00668027f0c495820a4377b02. --- python/semantic_kernel/agents/azure_ai/agent_thread_actions.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/python/semantic_kernel/agents/azure_ai/agent_thread_actions.py b/python/semantic_kernel/agents/azure_ai/agent_thread_actions.py index f02350b42759..7fdcce98ef82 100644 --- a/python/semantic_kernel/agents/azure_ai/agent_thread_actions.py +++ b/python/semantic_kernel/agents/azure_ai/agent_thread_actions.py @@ -290,7 +290,6 @@ def sort_key(step: RunStep): content = generate_bing_grounding_content( agent_name=agent.name, bing_tool_call=bing_call ) - is_visible = True case AgentsNamedToolChoiceType.AZURE_AI_SEARCH: logger.debug( f"Entering tool_calls (azure_ai_search) for run [{run.id}], agent " @@ -496,7 +495,6 @@ async def _process_stream_events( content = generate_streaming_bing_grounding_content( agent_name=agent.name, step_details=details ) - content_is_visible = True case AgentsNamedToolChoiceType.AZURE_AI_SEARCH: content = generate_streaming_azure_ai_search_content( agent_name=agent.name, step_details=details