Tools are executable functions that the LLM can choose to call, based on the tool’s description and the current context. You define tools in the subagent’s reasoning.actions block. Tools can be actions or other utilities.
Tools must wrap an action or a @utils function. Use with to bind parameters and set to assign output values to variables. You can use the available when parameter to deterministically specify when the tool is available.
Tools vs. Actions. Agent Script has two actions blocks:
Subagent actions (subagent.actions) — Available to you from logic-based reasoning instructions
Reasoning actions (subagent.reasoning.actions) — Available to the LLM to call as needed, and can be referenced in your prompt-based instructions
Since reasoning actions can reference subagents and utilities in addition to regular subagent actions, we sometimes call them “tools” to reflect their broader uses. In Canvas view, this distinction is handled automatically, but it’s important to understand when writing Agent Script directly.
Tip
How the LLM Decides Which Tool to Call
The LLM looks at the names and descriptions of all the tools when deciding whether to call a tool. Tools should have meaningful names and descriptions. To provide more context, you can explicitly reference a tool in the reasoning instructions.
For example, these reasoning instructions don’t provide additional context about which tool to call.
Example: No Specific Reasoning Instructions
1reasoning:2 instructions: ->3 | Use the action that best matches the user's message and the conversation context.4 actions:5 # This tool calls the Get_Customer_Info action6 lookup_customer: @actions.Get_Customer_Info7 with email=@variables.customer_email8 set @variables.customer_desc = @outputs.customer_description910 # This tool writes the customer-provided information11 # into the specified variables. The LLM can choose when to use it.12 capture_order_info: @utils.setVariables13 description: "Capture order search information from customer"14 with order_number=@variables.order_number15 with customer_email=@variables.customer_email16 available when @variables.customer_verified == True1718 # This tool transitions to a subagent that19 # displays detailed information about the order20 show_order_details: @utils.transition to @subagent.order_details21 description: "Show detailed order information"
These reasoning instructions provide more details about when to use the capture_order_info tool.
Example: Additional Context For Using the capture_order_info Tool
1reasoning:2 instructions: ->3 | If the customer is verified and provides their order number4 or email, use {!@actions.capture_order_info} to store the information.56 Otherwise, use the action that best matches the user's message and the conversation context.78 actions:9 # This tool calls the Get_Customer_Info action10 lookup_customer: @actions.Get_Customer_Info11 with email=@variables.customer_email12 set @variables.customer_desc = @outputs.customer_description1314 # This tool writes the customer-provided information15 # into the specified variables. The LLM can choose when to use it.16 capture_order_info: @utils.setVariables17 description: "Capture order search information from customer"18 with order_number=@variables.order_number19 with customer_email=@variables.customer_email20 available when @variables.customer_verified == True2122 # This tool transitions to a subagent that23 # displays detailed information about the order24 show_order_details: @utils.transition to @subagent.order_details25 description: "Show detailed order information"
Defining When a Tool Is Available
Use available when to define the conditions that must exist for the LLM to use the tool. The clause after available when must be a valid conditional expression built from supported operators.
Example: Available When
1reasoning:2 actions:3 cancel_booking: @actions.cancel_booking4 with booking_id=@variables.current_booking_id5 available when @variables.booking_status == "active"67 admin_override: @actions.admin_override8 available when @variables.user_role == "admin"910 go_to_identity: @utils.transition to @subagent.Identity11 description: "verifies user identity"12 available when @variables.verified == False
Referencing a Subagent as a Tool
In reasoning actions, you can reference a subagent directly with @subagent.<topic_name> or through a declarative transition (@utils.transition to). Use a direct @subagent.<topic_name> reference to delegate to a subagent, similar to an action or tool call. After the referenced subagent is run, the flow returns to the original subagent. This behavior is different from a declarative transition (@utils.transition to) in that transitions are one way, whereas a direct subagent reference returns to the original caller. If a referenced subagent includes a declarative transition, the flow follows that path until it ends, and then returns to the original subagent.
In this code sample, you can see both methods of calling another subagent.
Example: Using Subagents as Tools
1reasoning:2 actions:34 # Transitions to the other subagent and does not return5 show_order_details: @utils.transition to @subagent.order_details6 description: "Show detailed order information"78 # Runs the other subagent as a tool, synthesizes the result, then can run more tools9 consult_specialist: @subagent.specialist_topic10 description: "Consult specialist for complex questions"11 available when @variables.needs_expert_help == True