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 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())