Agent Script Reference: Tools (Reasoning Actions)

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 action
6        lookup_customer: @actions.Get_Customer_Info
7            with email=@variables.customer_email
8            set @variables.customer_desc = @outputs.customer_description
9
10        # This tool writes the customer-provided information
11        # into the specified variables. The LLM can choose when to use it.
12        capture_order_info: @utils.setVariables
13            description: "Capture order search information from customer"
14            with order_number=@variables.order_number
15            with customer_email=@variables.customer_email
16            available when @variables.customer_verified == True
17
18        # This tool transitions to a subagent that
19        # displays detailed information about the order
20        show_order_details: @utils.transition to @subagent.order_details
21            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 number
4           or email, use {!@actions.capture_order_info} to store the information.
5
6           Otherwise, use the action that best matches the user's message and the conversation context.
7
8    actions:
9        # This tool calls the Get_Customer_Info action
10        lookup_customer: @actions.Get_Customer_Info
11            with email=@variables.customer_email
12            set @variables.customer_desc = @outputs.customer_description
13
14        # This tool writes the customer-provided information
15        # into the specified variables. The LLM can choose when to use it.
16        capture_order_info: @utils.setVariables
17            description: "Capture order search information from customer"
18            with order_number=@variables.order_number
19            with customer_email=@variables.customer_email
20            available when @variables.customer_verified == True
21
22        # This tool transitions to a subagent that
23        # displays detailed information about the order
24        show_order_details: @utils.transition to @subagent.order_details
25            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_booking
4            with booking_id=@variables.current_booking_id
5            available when @variables.booking_status == "active"
6
7        admin_override: @actions.admin_override
8            available when @variables.user_role == "admin"
9
10        go_to_identity: @utils.transition to @subagent.Identity
11             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:
3
4        # Transitions to the other subagent and does not return
5        show_order_details: @utils.transition to @subagent.order_details
6            description: "Show detailed order information"
7
8        # Runs the other subagent as a tool, synthesizes the result, then can run more tools
9        consult_specialist: @subagent.specialist_topic
10            description: "Consult specialist for complex questions"
11            available when @variables.needs_expert_help == True

Related Topics