From 2b0485beda68858ae9edbc8fea168d0e3ae14256 Mon Sep 17 00:00:00 2001 From: Windsor Date: Sat, 26 Jul 2025 20:18:33 -0700 Subject: [PATCH 1/2] refactor: remove inherited method from Agent class --- src/agents/agent.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/agents/agent.py b/src/agents/agent.py index b67a12c0d..700d5706f 100644 --- a/src/agents/agent.py +++ b/src/agents/agent.py @@ -290,13 +290,6 @@ async def get_prompt( """Get the prompt for the agent.""" return await PromptUtil.to_model_input(self.prompt, run_context, self) - async def get_mcp_tools(self, run_context: RunContextWrapper[TContext]) -> list[Tool]: - """Fetches the available tools from the MCP servers.""" - convert_schemas_to_strict = self.mcp_config.get("convert_schemas_to_strict", False) - return await MCPUtil.get_all_function_tools( - self.mcp_servers, convert_schemas_to_strict, run_context, self - ) - async def get_all_tools(self, run_context: RunContextWrapper[Any]) -> list[Tool]: """All agent tools, including MCP tools and function tools.""" mcp_tools = await self.get_mcp_tools(run_context) From 23c286515a2e5a4c52e096e202366da82b3ce931 Mon Sep 17 00:00:00 2001 From: Windsor Date: Sat, 26 Jul 2025 20:35:44 -0700 Subject: [PATCH 2/2] refactor: remove inherited 'get_all_tools' method from Agent class --- src/agents/agent.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/agents/agent.py b/src/agents/agent.py index 700d5706f..23b0af6ca 100644 --- a/src/agents/agent.py +++ b/src/agents/agent.py @@ -289,23 +289,3 @@ async def get_prompt( ) -> ResponsePromptParam | None: """Get the prompt for the agent.""" return await PromptUtil.to_model_input(self.prompt, run_context, self) - - async def get_all_tools(self, run_context: RunContextWrapper[Any]) -> list[Tool]: - """All agent tools, including MCP tools and function tools.""" - mcp_tools = await self.get_mcp_tools(run_context) - - async def _check_tool_enabled(tool: Tool) -> bool: - if not isinstance(tool, FunctionTool): - return True - - attr = tool.is_enabled - if isinstance(attr, bool): - return attr - res = attr(run_context, self) - if inspect.isawaitable(res): - return bool(await res) - return bool(res) - - results = await asyncio.gather(*(_check_tool_enabled(t) for t in self.tools)) - enabled: list[Tool] = [t for t, ok in zip(self.tools, results) if ok] - return [*mcp_tools, *enabled]