Creating Tool Rules
Tool rules allows developer to define constrains on their tools, such as requiring that a tool terminate agent execution or be followed by another tool. We support the following tool rules:
TerminalToolRule(tool_name=...)
- If the tool is called, the agent ends executionInitToolRule(tool_name=...)
- The tool must be called first when an agent is runChildToolRule(tool_name=..., children=[...])
- If the tool is called, it must be followed by one of the tools specified inchildren
ParentToolRule(tool_name=..., children=[...])
- The tool must be called before the tools specified inchildren
can be calledConditionalToolRule(tool_name=..., child_output_mapping={...})
- If the tool is called, it must be followed by one of the tools specified inchildren
based off the tool’s outputContinueToolRule(tool_name=...)
- If the tool is called, the agent must continue executionMaxCountPerStepToolRule(tool_name=..., max_count_limit=...)
- The tool cannot be called more thanmax_count_limit
times in a single stepBy default, thesend_message
tool is marked withTerminalToolRule
, since you usually do not want the agent to continue executing after it has sent a message to the user.
For example, you can ensure that the agent will stop execution if either the send_message
or roll_d20
tool is called by specifying tool rules in the agent creation:
python
You can see a full working example of tool rules here.