Study guide
1.2 How an Agent Works & the Building Blocks of Agent Script
Salesforce Certified Agentforce Specialist Exam
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Exam Overview & How Agentforce Agents Work
1.1 Agentforce Specialist (AI-201) Exam Facts & Spring '26 Blueprint 1.2 How an Agent Works & the Building Blocks of Agent Script 1.3 Hybrid Reasoning: Agent Script in Canvas View and Script View
2 Chapter 2: Deterministic Control, Topics (Subagents) & Actions
2.1 Deterministic Behavior: Filters, Variables & Template Expressions 2.2 Standard and Custom Topics (Subagents) 2.3 Standard and Custom Agent Actions
3 Chapter 3: Agent Types, Security Context, Channels & Agent API
3.1 When to Use an Employee Agent or a Service Agent 3.2 Security Context: Who the Agent Runs As and How It Affects Actions 3.3 Connecting Agents to Channels: Digital Experiences, Email, Voice & Slack 3.4 When to Use the Agent API
4 Chapter 4: Prompt Builder Fundamentals
4.1 When to Use Prompt Builder 4.2 Access Controls Governing Prompt Templates 4.3 Prompt Template Types: Field Generation, Flex & More 4.4 Creating, Activating & Executing Prompt Templates
5 Chapter 5: Grounding, Prompt Best Practices, Trust Layer & Model Access
5.1 Choosing the Right Grounding Technique 5.2 Best Practices for Writing Effective Prompts 5.3 Einstein Trust Layer Security and Privacy Features 5.4 Managing and Preventing Access to Specific Models
6 Chapter 6: Data 360 Fundamentals for Agentforce
6.1 Agentforce Data Library: Types and Concepts 6.2 Chunking: Breaking Content Into Retrievable Units 6.3 Indexing and Search Types: Vector, Hybrid & Keyword 6.4 Retrievers: Individual, Ensemble & Filtered Retrieval
7 Chapter 7: Testing Agents with Testing Center
7.1 Testing an Agent with Testing Center 7.2 How Testing Center Evaluations Work
8 Chapter 8: Deploying Agents and Prompt Templates
8.1 Deploying an Agent from Sandbox to Production 8.2 Deploying Prompt Templates from Sandbox to Production
9 Chapter 9: Governance and Observability
9.1 Managing and Monitoring Agents 9.2 Agent Analytics and Agent Optimization
10 Chapter 10: Multi-Agent Orchestration, MCP & A2A
10.1 When a Multi-Agent Architecture Is Appropriate 10.2 Open Multi-Agent Protocols: MCP and A2A
1.2 How an Agent Works & the Building Blocks of Agent Script
Key Takeaways Explain This Topic AI
Every user message starts at the starting subagent, which by default is the Agent Router defined with the start_agent block.
Agentforce resolves a subagent's reasoning instructions top to bottom without an LLM, then sends the resolved prompt plus reasoning actions to the LLM.
Salesforce documents up to seven reasoning loops, and Agentforce Service agents run a final response validation before replying.
In Agent Script, the arrow (->) marks deterministic logic, the pipe (|) marks prompt text, and the at sign (@) references variables, actions, and subagents.
An agent's Agent Script lives in a .agent file inside the AiAuthoringBundle metadata component.
Last updated: September 2026
1.2 How an Agent Works & the Building Blocks of Agent Script
Quick Answer: Agentforce agents run on the Atlas reasoning engine , which Salesforce describes as graph-based : agents follow nodes, variables, and transitions instead of relying only on a long prompt. Each message goes to a starting subagent (by default the Agent Router ). The agent resolves reasoning instructions deterministically and then sends a focused prompt to the LLM. The LLM reasons over the allowed reasoning actions and responds. Agent Script is the language behind all of this.
This objective asks you to explain how an agent works and its basic building blocks. Exam scenarios usually test whether you know which parts run deterministically and which parts the LLM decides .
The Parts of an Agent
Building block What it is Who decides when it's used
Agent-level (system) instructions and messages Persona and global guidance, plus required welcome and error messages Included in every prompt
Subagents (formerly topics) A job the agent can do, with a name, description, reasoning instructions, and actions The Agent Router classifies to one, or logic transitions to one
Reasoning instructions A mix of deterministic logic and natural-language prompt text Logic runs in order; prompt text goes to the LLM
Actions Tools backed by flows, Apex, prompt templates, APIs, or MCP tools Either run deterministically in instructions or chosen by the LLM as reasoning actions
Variables Stored state that persists across turns Set by logic, action outputs, or the LLM through a utility
Connections Channel settings such as Messaging, Enhanced Chat v2, Slack, or telephony Determine where and how the agent responds
The Runtime Journey of a Message
Salesforce Help breaks the journey into seven steps:
A user sends a message.
The agent goes to the starting subagent. In Agent Script, that's the block that uses the start_agent prefix. By default it's the Agent Router , which compares the recent conversation with subagent names and descriptions. From April 2026, agents built from the default Employee and Service agent templates in the new builder use the Salesforce-owned HyperClassifier model for this classification step.
The agent resolves the subagent's reasoning instructions top to bottom. No LLM is involved yet. Resources are replaced with values, inline actions run, and conditions are evaluated. If logic triggers a transition , the agent moves to the other subagent before any reasoning happens.
The agent builds a prompt from four ingredients: agent-level instructions, recent conversation history, the resolved subagent instructions, and the subagent's reasoning actions.
The LLM reasons and acts. It can run an action or utility, ask for more information, ask a clarifying question, or answer directly. After each action it reviews the output and decides the next step. Salesforce documents up to seven reasoning loops .
Agentforce Service agents validate the final response. The response is checked for grounding, scope and instruction adherence, hallucinations, and possible prompt injection. If it fails, the agent generates a new one. If no response passes, the agent tells the user it can't help. This step applies to Service agents only.
The agent sends the response. The user's next message starts the journey again.
Loading diagram... Runtime journey of one user message
Agent Script: The Language Behind the Builder
Whether you edit in Canvas view , edit in Script view , or ask the Agentforce assistant to make changes, you're producing Agent Script . The script is stored in a .agent file inside the AiAuthoringBundle metadata component, which developers can retrieve into a Salesforce DX project and edit in VS Code with Agentforce DX.
Core syntax
- Symbol Meaning Example
- key: value Property-based declarations agent_name: "OrderHelper"
Indentation Defines structure; use spaces, not tabs Nested blocks under reasoning:
- @ References a resource defined in the script @variables.order_id , @actions.get_order , @subagent.Escalation
- > Starts logic instructions that run deterministically instructions: ->
| Starts prompt text that goes to the LLM | Help the customer with their order.
{! } Template expression that resolves a value into prompt text {!@variables.customer_name}
... Slot-fill token: the LLM supplies an action input with order_id = ...
- # Comment # verify before lookup
- The main blocks
system – Agent-level instructions and the required welcome and error messages. A subagent can override system.instructions when it needs a different persona.
config – Agent identity such as agent_name . Agentforce Service agents also need default_agent_user , the agent user the agent runs as; Employee agents don't require it.
variables – Global state. Linked variables map to a source such as a Messaging Session field; mutable variables hold custom values.
language and connection – Supported locales and channel connections such as Enhanced Chat.
start_agent – The entry point for every user message, normally the Agent Router.
subagent blocks – Each has a description , action definitions ( actions: with targets such as flow://Get_Order ), and a reasoning: block with instructions and reasoning actions . The older topic keyword is deprecated in favor of subagent .
after_reasoning – Optional logic that runs after the reasoning loop exits.
A small example system:
instructions: "You are a friendly agent that helps customers with orders."
messages:
- welcome: "Hi! How can I help with your order today?"
- error: "Sorry, something went wrong."
variables:
- is_premium: mutable boolean = False
- description: "Whether the customer is a premium member"
start_agent agent_router:
description: "Welcome the user and route to the right subagent"
reasoning:
instructions: ->
if @variables.is_premium:
| Thank the customer for being a premium member.
else:
| Offer information about the premium program.
When is_premium is True , the LLM receives only the "thank the customer" line. The other branch never reaches the prompt. That selective, logic-driven prompt construction is the foundation of hybrid reasoning , covered in the next section.
Two Ways to Call an Action
Where the action appears Behavior Use it when
In reasoning instructions with run @actions.name Runs deterministically before reasoning; you must bind inputs ( with ) and store outputs ( set ) yourself The step must always happen, such as loading an order summary before the conversation continues
In reasoning actions ( reasoning: actions: ) Exposed as a tool the LLM may choose , guided by its description and any available when filter The user's request should decide whether the action runs
Exam Traps
Classification isn't the whole engine. The Agent Router selects a subagent, but logic inside the subagent can transition elsewhere before any LLM call.
Logic doesn't use the LLM. Conditions, run , set , and transition to in instructions all execute before reasoning.
Final response validation is Service-agent specific. Don't attribute it to Employee agents.
Descriptions matter. Subagent descriptions drive classification, and action descriptions drive tool choice.