From 30d70c1e30c3025d523b7b671a6b0951ea591d18 Mon Sep 17 00:00:00 2001 From: ymuichiro Date: Thu, 9 Oct 2025 02:37:55 +0900 Subject: [PATCH 1/2] Fix function choice behavior handling in ResponsesAgentThreadActions --- .../open_ai/responses_agent_thread_actions.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/python/semantic_kernel/agents/open_ai/responses_agent_thread_actions.py b/python/semantic_kernel/agents/open_ai/responses_agent_thread_actions.py index d2375a9f3ce4..087597c342e3 100644 --- a/python/semantic_kernel/agents/open_ai/responses_agent_thread_actions.py +++ b/python/semantic_kernel/agents/open_ai/responses_agent_thread_actions.py @@ -1209,10 +1209,19 @@ def _get_tools( if agent.tools: tools.extend(agent.tools) - # TODO(evmattso): make sure to respect filters on FCB - if kernel.plugins: - funcs = kernel.get_full_list_of_function_metadata() - tools.extend([kernel_function_metadata_to_response_function_call_format(f) for f in funcs]) + if not function_choice_behavior.enable_kernel_functions: + return tools + + if not kernel.plugins: + return tools + + funcs = ( + kernel.get_list_of_function_metadata(function_choice_behavior.filters) + if function_choice_behavior.filters + else kernel.get_full_list_of_function_metadata() + ) + + tools.extend([kernel_function_metadata_to_response_function_call_format(f) for f in funcs]) return tools From 4839a4b2c1d2560d090bff0283847361ae5bf708 Mon Sep 17 00:00:00 2001 From: ymuichiro Date: Fri, 17 Oct 2025 15:12:45 +0900 Subject: [PATCH 2/2] Fix: avoid NotImplementedError when function_choice filters are non-dict in Responses agent --- .../openai_responses/test_openai_responses_thread_actions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/tests/unit/agents/openai_responses/test_openai_responses_thread_actions.py b/python/tests/unit/agents/openai_responses/test_openai_responses_thread_actions.py index 80b514b70f07..ba0473efe8d7 100644 --- a/python/tests/unit/agents/openai_responses/test_openai_responses_thread_actions.py +++ b/python/tests/unit/agents/openai_responses/test_openai_responses_thread_actions.py @@ -15,6 +15,7 @@ from semantic_kernel.agents.open_ai.openai_responses_agent import OpenAIResponsesAgent from semantic_kernel.agents.open_ai.responses_agent_thread_actions import ResponsesAgentThreadActions +from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior from semantic_kernel.contents.chat_message_content import ChatMessageContent from semantic_kernel.contents.streaming_chat_message_content import StreamingChatMessageContent from semantic_kernel.contents.streaming_text_content import StreamingTextContent @@ -499,11 +500,11 @@ async def mock_invoke_function_call(*args, **kwargs): def test_get_tools(mock_agent, kernel, custom_plugin_class): kernel.add_plugin(custom_plugin_class) - + fcb = FunctionChoiceBehavior() tools = ResponsesAgentThreadActions._get_tools( agent=mock_agent, kernel=kernel, - function_choice_behavior=MagicMock(), + function_choice_behavior=fcb, ) assert len(tools) == len(mock_agent.tools) + len(kernel.get_full_list_of_function_metadata())