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 added 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 runToolRule(tool_name=..., children=[...])
- If the tool is called, it must be followed by one of the tools specified inchildren
By default, the
send_message
tool is marked with TerminalToolRule
, since you usually do not want to agent to continue executing after it has send 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.