Skip to content

Commit 4ca08e4

Browse files
committed
Add DynamicToolset validation and export TemporalDynamicToolset
1 parent db55bb0 commit 4ca08e4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pydantic_ai_slim/pydantic_ai/durable_exec/temporal/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from ...exceptions import UserError
1616
from ._agent import TemporalAgent
17+
from ._dynamic_toolset import TemporalDynamicToolset
1718
from ._function_toolset import TemporalFunctionToolset
1819
from ._logfire import LogfirePlugin
1920
from ._mcp import TemporalMCPToolset
@@ -28,6 +29,7 @@
2829
'AgentPlugin',
2930
'TemporalRunContext',
3031
'TemporalWrapperToolset',
32+
'TemporalDynamicToolset',
3133
'TemporalFunctionToolset',
3234
'TemporalMCPToolset',
3335
'PydanticAIWorkflow',

pydantic_ai_slim/pydantic_ai/durable_exec/temporal/_agent.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def _validate_temporal_toolsets(toolsets: Sequence[AbstractToolset[AgentDepsT]],
5050
"""Validate that all leaf toolsets requiring temporal wrapping are properly wrapped.
5151
5252
This function recursively traverses the toolset hierarchy and checks that any leaf
53-
toolsets that need temporal wrapping (FunctionToolset, MCPServer, FastMCPToolset)
53+
toolsets that need temporal wrapping (FunctionToolset, MCPServer, FastMCPToolset, DynamicToolset)
5454
are wrapped in a TemporalWrapperToolset.
5555
5656
Args:
@@ -73,10 +73,15 @@ def validate_toolset(t: AbstractToolset[AgentDepsT]) -> AbstractToolset[AgentDep
7373
if isinstance(t, TemporalWrapperToolset):
7474
return t
7575

76-
# Check if this is a FunctionToolset that needs wrapping
7776
if isinstance(t, FunctionToolset):
7877
raise UserError(error_msg)
7978

79+
# Check if this is a DynamicToolset that needs wrapping
80+
from pydantic_ai.toolsets._dynamic import DynamicToolset
81+
82+
if isinstance(t, DynamicToolset):
83+
raise UserError(error_msg)
84+
8085
# Check if this is an MCPServer that needs wrapping
8186
try:
8287
from pydantic_ai.mcp import MCPServer

0 commit comments

Comments
 (0)