-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Description
In scenarios where agents need to be defined dynamically (example), the list of agent tools cannot be registered by the agent when the temporal worker is created, since the agent is not yet created.
Please decouple tool registration and naming from agent definition and naming in order to allow multiple agents (and dynamically created agents) within a temporal workflow to use the same set of registered tools. A master list of tools would be registered with the temporal workflow at the time of workflow creation, and dynamically created agents could refer to and use the subset of those tools as needed.
For example, if the tool naming (currently something like agent__{name}__tool__{tool_name}) were to not include the agent name and instead be a workflow-wide tool, then dynamic agents could refer to the tool by its name/slug.
It would be nice to have a helper function for temporal workflow tool registration as well.
References
From the slack conversation with @DouweM :
That would be pretty easy to make work -- you can already create a
FunctionToolsetand then manually wrap it in aTemporalFunctionToolset(currently private) and then pass thetemporal_function_toolset.temporal_activitiesto the worker. The only part that isn't done yet is letting you pass thoseTemporalFunctionToolsets toTemporalAgent.run(toolsets=...), which would require replacing this error with a check that all the toolsets are properly wrapped for Temporal:pydantic-ai/pydantic_ai_slim/pydantic_ai/durable_exec/temporal/_agent.py
Lines 898 to 901 in c1213e4
if toolsets is not None: raise UserError( 'Toolsets cannot be set at agent run time inside a Temporal workflow, it must be set at agent creation time.' )
Related to: