---
schema_version: "1"
id: b60d33e65fae24fef0b9ae162c836d32f262c2a7b088f2fcfec39ae8a7cc29b2
title: How Agents Created in the Legacy Builder Work
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ai/264-0-0/agent_reasoning_engine.md
canonical_url: https://help.salesforce.com/s/articleView?id=ai.agent_reasoning_engine.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 4bffcb540a95cc9453e023e115f01b99c4813f33b55c422da93fc2becc6213dc
description: Follow the path of a user message through the Atlas reasoning engine to learn how an agent built in the legacy Agentforce Builder reasons, takes action, and generates responses.
products:
  - Agentforce
  - Cross Cloud
release: "264"
---
# How Agents Created in the Legacy Builder Work

Follow the path of a user message through the Atlas reasoning engine to learn how an agent built in the legacy Agentforce Builder reasons, takes action, and generates responses.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions. <a href="https://help.salesforce.com/s/articleView?id=ai.agent_setup_explore_types.htm&amp;release=264.0.0&amp;type=5" title="Learn about agent types and default templates for specific clouds and common use cases.">Required add-on licenses vary by agent type.</a></td></tr></tbody></table>

![An overview of how an agent processes a question or request](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ai-generative_ai-264-0-0-production-enus/f8ef6498-d7b2-44e3-9b34-ffd5a850aae9/generative_ai/images/agent_reasoning_engine.png)

You can think of the reasoning engine as a series of carefully orchestrated prompts sent to a large language model (LLM). Each step in the agent’s iterative classification and reasoning represents one or more LLM calls. The number and size of LLM calls depends on the complexity of the task and which subagents and actions are used. [Learn more about large language model support for Agentforce.](https://help.salesforce.com/s/articleView?id=ai.copilot_considerations.htm&release=264.0.0&type=5 "Carefully review the support, limits, and considerations for AI agents.")

## Step 1: A user sends a message

If an agent uses a conversational interface, the process begins when a user enters a question or request.

Agents that operate in the background behave differently.

- [Agentforce SDR agents](https://help.salesforce.com/s/articleView?id=sales.sales_agent_sdr_parent.htm&type=5&language=en_US)—The process begins when the agent initiates contact with a prospect based on a lead assignment, schedule, and other engagement rules that you set.
- [Agents called from an Apex class or flow](https://help.salesforce.com/s/articleView?id=ai.agent_custom_invocable_action_flow_apex.htm&release=264.0.0&type=5 "Give your users access to your agent’s subagents, actions, and reasoning capabilities to automate repetitive tasks and provide real-time assistance. Use invocable actions to call an Agentforce Service agent, Agentforce Employee agent, or Agentforce (Default) from a flow or Apex class. You can call an agent to complete background or event-driven tasks from anywhere that you can invoke a flow or Apex class.")—The process begins when the agent is triggered based on the conditions you set. When you configure your Apex class or flow, you define the agent’s task by specifying a sample user message. The agent uses the same user message to search through the subagents and actions assigned to it, just like if a user had asked a question or made a request in a chat window.

## Step 2: The agent classifies the user’s message into a subagent

The agent selects the best matching subagent based on what the user wants to do and the jobs that the agent can do. To do this, the reasoning engine compares the recent conversation history, including the user’s most recent message, to the names and classification descriptions of all the subagents available to the agent. Subagents with a filter applied are included only if the filter conditions are met.

After a subagent is selected, the reasoning engine collects all of the information that the agent needs to determine its next step.

- The recent conversation history, including the most recent user message (on average, the last six turns of the conversation).
- The subagent’s name, scope, and instructions.
- The names and instructions, including input and output instructions, of the actions included in the subagent. Actions with a filter applied are included only if the filter conditions are met.

Then the agent moves on to the reasoning process.

If the reasoning engine can't find an appropriate subagent, the agent moves to an Off-Topic system subagent and tries to bring the conversation back to the subagents assigned to it.

## Step 3: The agent begins the reasoning process and takes action

After the agent has selected a subagent, it analyzes the available information to determine its next step.

- Run an agent action
    
    If the agent needs to retrieve or update information, it can use one or more agent actions to call a Salesforce service, such as an Apex class, flow, or prompt template. [Learn more about agent actions.](https://help.salesforce.com/s/articleView?id=ai.copilot_actions.htm&release=264.0.0&type=5 "Actions are how agents get things done. Agents include a library of actions, which are the tools an agent can use to do its job. For example, if a user asks an agent for help with writing an email, the agent first selects a subagent, then it launches an action that drafts and revises the email and grounds it in relevant Salesforce data.")
    
    An agent also uses actions to ground a response in trusted business data and other sources, such as knowledge articles and external websites. [Learn more about grounding agents in your data.](https://help.salesforce.com/s/articleView?id=ai.agent_parent_data.htm&release=264.0.0&type=5 "A great agent uses your data to provide high-quality responses. Learn about methods for connecting agents to knowledge sources, including internal data, unstructured documents, and web search.")
- Ask the user for more information
    
    If the agent requires information outside the conversation history, the agent can ask the user directly.
- Ask the user clarifying questions
    
    The agent can ask follow-up questions to disambiguate between available options.
- Respond directly to the user’s question or request
    
    If the user’s question or request can be resolved with information the agent already has access to, the agent can respond without running additional actions.

The agent’s decision-making is heavily influenced by subagent instructions. For example, if a subagent instruction specifies that the agent should always ask for a model number before answering a product-related question, the agent requests the information before moving to the next step. Or if a subagent instruction specifies that the agent must verify a customer’s identity before providing account information, the agent moves to a customer verification subagent before fulfilling the user’s request. [Learn more about subagent instructions.](https://help.salesforce.com/s/articleView?id=ai.copilot_topics_instructions.htm&release=264.0.0&type=5 "Subagent instructions set guidelines for agent behavior and give an agent the context it needs to do its job. Review best practices for writing subagent instructions to reduce latency and help your agent respond accurately and consistently.")

When the agent runs an action, it checks the result in a reasoning loop to make sure it has the right information before responding to the user. The agent adds the action output to the information it already has about the conversation. Then it decides whether to run another action, ask the user more questions, or send a final response. This process continues up to seven reasoning loops.

## Step 4: The agent performs a final response validation (Agentforce Service agents only)

Before an Agentforce Service agent sends a response, it checks whether the response is grounded in data sources, adheres to the subagent’s scope and instructions, and doesn’t include hallucinations, unverified information, or potential prompt injection risks. If the proposed response fails this validation, the agent generates a new response.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ai-generative_ai-264-0-0-production-enus/f8ef6498-d7b2-44e3-9b34-ffd5a850aae9/images/icon_note.png)

Note Agents stream LLM responses in conversations as the responses are received. The response validation is applied to the final agent response. If a proposed response fails this validation after the response has started streaming, the response is deleted and a new response is generated.

If the agent can’t generate a response that passes validation, it informs the user that it can’t help with their question or request.

## Step 5: The agent sends a response to the user

After the agent completes the reasoning loop, it sends a message to the user. The user can continue the conversation by asking a follow-up question or changing the subject, and the agent responds appropriately. Behind the scenes, the user’s response restarts the journey, but to the user, it feels like they’re taking turns in a conversation.