How Subagent Instructions are Resolved to Build a Prompt

Learn about how an agent executes programmatic expressions in a subagent’s reasoning instructions to prepare for reasoning.

Required Editions

Available in: Lightning Experience
Available in: Enterprise, Performance, Unlimited, and Developer Editions. Required add-on licenses vary by agent type.
Note
Note Beginning in April 2026, agent topics are now called subagents. There are no changes to functionality. During this transition, you may see a mix of the new and previous terms in our documentation.

Reasoning instructions are the guidelines that tell your agent how to handle conversations in the context of the subagent, your business case, and the conversation in general. They contain a combination of programmatic logic and natural language prompts, where logic reliably handles your agent’s general workflow and business rules and prompts more flexibly guide your agent’s conversational skills. You can think of logic in reasoning instructions as anything the agent must do before reasoning, and natural language prompts as anything the agent should take into account during reasoning.

When an agent moves to a subagent, it begins resolving the subagent’s reasoning instructions from top to bottom, in the order that they’re written. This process can include:

  • Replacing references to resources (like variables or actions) with actual values, including manually setting values
  • Running any inline actions and inserting the results into the instructions
  • Evaluating and applying any conditional statements

At this stage in the subagent’s execution, no reasoning takes place, so the agent doesn’t rely on an LLM yet. Every logical expression in reasoning instructions is run, run exactly as written, and run in the order that it’s written.

If at any point in the reasoning instructions the agent executes a transition to another subagent, the agent redirects the conversation before the instructions are resolved and any reasoning occurs. Otherwise, when the agent reaches the end of the reasoning instructions, it injects the resolved reasoning instructions into a prompt to send to the LLM and kick off the reasoning process. The prompt includes:

  • Agent-level instructions, which apply to every agent interaction
  • The recent conversation history, including the user’s most recent message
  • The resolved subagent reasoning instructions
  • Reasoning actions associated with the subagent, which are the actions (including agent actions) an agent is allowed to take during its reasoning process

The agent uses the LLM to analyze the available information in the prompt and determine its next steps.

Example

An agent is chatting with a customer who is expecting a delivery. The customer’s order ID is 1234 and the estimated delivery date is February 10, 2026, which is outside of the expected delivery window.

Based on the customer’s message, the agent selects a subagent that contains the following reasoning instructions.

reasoning:
  instructions:->
    If @variables.updated_delivery_date == None
      run @actions.get_delivery_date 
        with order_ID=@variables.order_ID
        set @variables.updated_delivery_date=@outputs.delivery_date

      | Tell the user that the expected delivery date for order number {!@variables.order_ID} is {!@variables.updated_delivery_date}. 

    If @variables.is_late == None
      run @actions.check_if_late
        with order_ID=@variables.order_ID
        with delivery_date=@variables.updated_delivery_date
        set @variables.is_late = @outputs.is_late

    if @variables.is_late == "true":
      | Apologize to the customer for the delay in receiving their order.

To construct a prompt, Agentforce resolves the reasoning instructions line by line, following these steps.

  1. Run the action get_delivery_date to get an expected delivery date.
  2. Set the variable updated_delivery_date to the value of outputs.delivery_date, which was returned by the action. In this case, the value is set to February 10, 2026.
  3. Add this instruction to the prompt: Tell the user that the expected delivery date for order number 1234 is February 10, 2026.
  4. Run the action check_if_late.
  5. Set the variable is_late to the value of outputs.is_late, which was returned by the action. In this case, the variable is set to "True".
  6. Check whether the value of if @variables.is_late == "True" to determine whether the order is late.
  7. Because the order is late, add this instruction to the prompt: Apologize to the customer for the delay in receiving their order.

These are the resolved reasoning instructions that are added to the prompt.

Tell the user that the expected delivery date for the order number 1234 is February 10, 2026. 
Apologize to the customer for the delay in receiving their order.

The prompt is sent to the LLM to determine the agent’s next steps and generate a response.