Agent Script Reference: Reasoning Instructions

A subagent’s reasoning block contains instructions that Agentforce resolves into a prompt for the LLM. The resolved prompt instructs the LLM to perform the subagent’s purpose. See Processing a Subagent.

In general, shorter reasoning instructions result in more accurate and reliable results.

Note

In the example, the logic deterministically sends a verification code when an email address is present and saves returned values in variables. The prompt guides the user to provide and validate the code, with instructions to confirm the email and resend if needed.

Reasoning Instructions: Appointment Options Prompt
1reasoning:
2    instructions: ->
3      if @variables.member_email != "":
4        run @actions.send_verification_code
5          with email=@variables.member_email
6          with member_number = @variables.member_number
7          set @variables.verification_code=@outputs.verification_code
8          set @variables.member_name=@outputs.member_name
9
10      | Greet the user and inform them that to help them get started you've sent them a verification code via email.
11        Ask the user for the verification code they received and verify it using {!@actions.validate_verification_code}.
12        If the user says they did not receive the code, ask them to confirm their email and resend the verification code using {!@actions.send_verification_code}

To use variables in reasoning instructions, use {!@variables.<variable_name>}. The prompt is resolved with the variable’s value.

There are two different parts of reasoning instructions: logic instructions and prompt instructions. Logic instructions are deterministic or conditional expressions that determine certain requirements, run actions, and set variables. Prompt instructions are passed as natural language to the LLM if the conditions are met. The prompt instructions can still reference literal values through @variables, @utils, and @actions.

The | (pipe) command for multiline strings can also be used for indented multiline prompt instructions before or after the deterministic logic instructions are followed.

Logic and Prompt Instructions
1reasoning:
2    instructions: ->
3        # LOGIC INSTRUCTIONS
4        if @variables.ready_to_book:
5            run @actions.get_account_info
6                with account_id=@variables.account_id
7                set @variables.hotel_code=@outputs.hotel_code
8        run @actions.get_hotel_info
9            with hotel_code=@variables.hotel_code
10            set @variables.hotel_info = @outputs.hotel_info
11
12        # PROMPT INSTRUCTIONS
13        | You are a helpful assistant that can answer questions about a hotel.
14          Here's the latest hotel information {!@variables.hotel_info}. If the user
15          asks about availability, please use the action: {!@actions.get_availability} action
16          that they give you the date range they are traveling on.
17          If they indicate they wish to book, please transition over
18          to a booking agent by calling the action {!@actions.transition_to_booking} action.
19          If they indicate that they wish to ask about another hotel, use the {!@actions.lookup_hotel}
20          action and tell them they'll be able to ask about that hotel.

Related Topics