Sub topic 3
Actions: calling backend capabilities
This chapter assumes you understand LLM agents, prompts, conversation turns, variables, conditions, and function calls. Agent Script uses actions to connect model decisions to backend operations.
Actions call backend capabilities
An action is a named capability that an agent can invoke. It might look up an order, create a case, or update a record. The backend performs the operation; the model supplies conversational judgement around when to use it.
topic order_status:
description: "Answer questions about an existing order"
reasoning:
instructions: ->
if @variables.order_id == "":
| Ask for the order number.
else:
| Use the order lookup action for {[email protected]_id}.
actions:
lookup_order: @actions.lookup_orderThe script exposes lookup_order to this topic. Keep important checks in the script instead of relying on the model to remember them.
Transitions move work between topics
A transition changes the active topic. The starting topic can route the request, and a later topic can handle the detailed task.
start_agent topic_selector:
description: "Route the customer's request"
reasoning:
instructions: ->
| Decide whether the request concerns an order.
actions:
go_to_order_status: @utils.transition to @topic.order_statusThe model can choose the transition, but the destination is fixed by the script. This combines flexible language understanding with controlled routing.
Limit available actions
An action should be available only where it makes sense. Exposing a refund action in a general greeting topic increases the chance of an unsafe or incorrect call. Define actions inside the topic or instruction block that needs them, and use conditions to delay them until required state exists.
Guard required sequences
A common pattern is collect, validate, then act. Store collected values in variables, branch on whether they are present, and expose the next action only after validation. Use transitions to move to a confirmation topic before an irreversible operation.
Test and refine
Test representative conversations, including missing values, invalid values, ambiguous requests, repeated requests, and attempts to skip confirmation. Record which topic, condition, and action ran. Revise the script when the observed path differs from the required path.
Exercise
How would you prevent an order lookup from running before the customer provides an order number?
Show answer
Store the number in a variable, condition on whether it is empty, and expose the lookup action only in the branch where the number is present.