Skip to content

Commit 75065ba

Browse files
refactor: remove inherited method from Agent class (#1267)
1 parent a64208c commit 75065ba

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

src/agents/agent.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -289,30 +289,3 @@ async def get_prompt(
289289
) -> ResponsePromptParam | None:
290290
"""Get the prompt for the agent."""
291291
return await PromptUtil.to_model_input(self.prompt, run_context, self)
292-
293-
async def get_mcp_tools(self, run_context: RunContextWrapper[TContext]) -> list[Tool]:
294-
"""Fetches the available tools from the MCP servers."""
295-
convert_schemas_to_strict = self.mcp_config.get("convert_schemas_to_strict", False)
296-
return await MCPUtil.get_all_function_tools(
297-
self.mcp_servers, convert_schemas_to_strict, run_context, self
298-
)
299-
300-
async def get_all_tools(self, run_context: RunContextWrapper[Any]) -> list[Tool]:
301-
"""All agent tools, including MCP tools and function tools."""
302-
mcp_tools = await self.get_mcp_tools(run_context)
303-
304-
async def _check_tool_enabled(tool: Tool) -> bool:
305-
if not isinstance(tool, FunctionTool):
306-
return True
307-
308-
attr = tool.is_enabled
309-
if isinstance(attr, bool):
310-
return attr
311-
res = attr(run_context, self)
312-
if inspect.isawaitable(res):
313-
return bool(await res)
314-
return bool(res)
315-
316-
results = await asyncio.gather(*(_check_tool_enabled(t) for t in self.tools))
317-
enabled: list[Tool] = [t for t, ok in zip(self.tools, results) if ok]
318-
return [*mcp_tools, *enabled]

0 commit comments

Comments
 (0)