File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -150,8 +150,8 @@ def __init__(
150150 async def _apply_tool_filter (
151151 self ,
152152 tools : list [MCPTool ],
153- run_context : RunContextWrapper [Any ],
154- agent : AgentBase ,
153+ run_context : RunContextWrapper [Any ] | None = None ,
154+ agent : AgentBase | None = None ,
155155 ) -> list [MCPTool ]:
156156 """Apply the tool filter to the list of tools."""
157157 if self .tool_filter is None :
@@ -163,6 +163,8 @@ async def _apply_tool_filter(
163163
164164 # Handle callable tool filter (dynamic filter)
165165 else :
166+ if run_context is None or agent is None :
167+ raise UserError ("run_context and agent are required for dynamic tool filtering" )
166168 return await self ._apply_dynamic_tool_filter (tools , run_context , agent )
167169
168170 def _apply_static_tool_filter (
@@ -312,8 +314,6 @@ async def list_tools(
312314 # Filter tools based on tool_filter
313315 filtered_tools = tools
314316 if self .tool_filter is not None :
315- if run_context is None or agent is None :
316- raise UserError ("run_context and agent are required for dynamic tool filtering" )
317317 filtered_tools = await self ._apply_tool_filter (filtered_tools , run_context , agent )
318318 return filtered_tools
319319
You can’t perform that action at this time.
0 commit comments