Skip to content

Commit 0c96126

Browse files
committed
Require WrapperToolset subclasses to implement their own prepare_for_run
1 parent a6eba43 commit 0c96126

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pydantic_ai_slim/pydantic_ai/toolset.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ async def __aexit__(
441441
) -> bool | None:
442442
return await self.wrapped.__aexit__(exc_type, exc_value, traceback)
443443

444+
@abstractmethod
445+
async def prepare_for_run(self, ctx: RunContext[AgentDepsT]) -> RunToolset[AgentDepsT]:
446+
raise NotImplementedError()
447+
444448
@property
445449
def tool_defs(self) -> list[ToolDefinition]:
446450
return self.wrapped.tool_defs

tests/test_mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def get_none() -> None: # pragma: no cover
232232
with pytest.raises(
233233
UserError,
234234
match=re.escape(
235-
"MCPServerStdio(command='python', args=['-m', 'tests.mcp_server'], tool_prefix=None) defines a tool whose name conflicts with existing tool from FunctionToolset: 'get_none'. Consider setting `tool_prefix` to avoid name conflicts."
235+
"MCPServerStdio(command='python', args=['-m', 'tests.mcp_server'], tool_prefix=None) defines a tool whose name conflicts with existing tool from Function toolset: 'get_none'. Consider setting `tool_prefix` to avoid name conflicts."
236236
),
237237
):
238238
await agent.run('Get me a conflict')

0 commit comments

Comments
 (0)