Agent Script Pattern: Reference Resources Directly in Reasoning Instructions
Reference subagents, actions, and variables directly in the prompt text of your reasoning instructions. Use @ mentions and the {curly brace} syntax to reference variables and reasoning actions directly.
Why Use This Pattern
Reference subagents, actions, and variables directly in your reasoning instructions using special syntax. Use @ mentions and the curly brace syntax to reference variables and actions directly in your prompt text.
Pattern Example: Display a personalized order summary by referencing variables like order name, date, and status, and guide the user to the lookup_order action or Returns subagent when they need more help.
Reference Syntax
Subagents: {!@subagents.<subagent_name>}
Actions: {!@actions.<action_name>}
Variables: {!@variables.<variable_name>}
Reference Variables in Output
Reference variables directly to include specific data in the response.
Variable References in Output
1reasoning:2 instructions: ->3 | Refer to the user by preferred name {!@variables.preferred_name}.4 Output a summary to the user in the following format:5 Order Name: {!@variables.order_name}6 Order Date: {!@variables.order_date}7 Order Status: {!@variables.order_status}
Reference Actions in Instructions
Reference actions directly to tell the LLM which reasoning action to use.
Action References in Instructions
1reasoning:2 instructions: ->3 | If the user wants information about a past order, ask for the Order ID4 or Restaurant Name and use {!@actions.lookup_order}.5 If the user asks for a service agent or seems upset,6 go to {!@actions.go_to_escalation}.7 If the user wants to make a return, confirm their order ID and8 call {!@actions.create_return}.
Combine Variable and Action References
Use both types of references together for complete, specific instructions.
Combined References
1reasoning:2 instructions: ->3 | Refer to the user by their name {!@variables.member_name}.4 Show the user their current order summary: {!@variables.order_summary}5 at the start of the conversation or if they specifically request it again.6 If the user wants to make a return, confirm their order ID and7 call {!@actions.create_return}. If returns are not eligible8({!@variables.order_return_eligible} is False), explain that9 the order is not eligible for return.
Conditional Output with References
Use references inside conditional prompts as well.
Conditional Variable References
1reasoning:2 instructions: ->3 if @variables.loyalty_tier == "Gold":4 | Thank the customer for being a Gold member.5 Their current points balance is {!@variables.points_balance}.67 if @variables.loyalty_tier == "Platinum VIP":8 | Welcome back, valued Platinum VIP member {!@variables.member_name}!9 You have {!@variables.points_balance} points available.
Tips
Reference resources when clarity is required: In general, the agent can figure out which resource to use. In cases where you have many actions, for example, add a reference to help the agent pick the right one. Direct references are a stronger signal to the LLM, so it’s more likely to select the right variable, action, or subagent.