Sub topic 1
What an Agentforce Agent Is
An Agentforce agent is a Salesforce AI agent. It reads a user's request in natural language, decides what the user is asking for, and does the work by running actions you have configured. This chapter defines the parts of an agent and shows how they fit together. Later chapters go into each part in detail.
Prerequisites
This chapter assumes you already know the following:
- Basic Salesforce concepts: objects, records, and where to find things in Setup.
- Flow or Apex at a high level. You do not need to write either one yet.
- What a large language model (LLM) does: it takes text in and produces text out.
You do not need any prior Agentforce experience.
What an agent does
A traditional chatbot follows a fixed script. A developer writes a decision tree, and the bot walks down it. If the user says something the tree does not cover, the bot fails.
An Agentforce agent works differently. You do not script every path. You describe what the agent is responsible for, what it may do, and how it should behave. At run time, an LLM reads the user's message and decides which of those responsibilities applies and which action to run.
The agent's behavior is therefore the combination of two things:
- The configuration you write: topics, instructions, and actions.
- The reasoning an LLM does over that configuration for each request.
Because the LLM decides, the text you write matters. Descriptions and instructions are not documentation for humans. They are the input the model uses to choose.
The parts of an agent
An agent is built from a small number of pieces.
| Part | What it is | Who writes it |
|---|---|---|
| Agent | The overall assistant, with a role, a company context, and the topics it can handle | You, in Agentforce Builder |
| Topic | One area of responsibility, such as order support | You |
| Instructions | Natural-language rules that apply inside a topic | You |
| Action | A unit of work the agent can run, such as a Flow or an Apex method | You, or a developer |
| Reasoning engine | The component that uses an LLM to pick topics and actions | Salesforce |
The first four are configuration. The last one is the platform's runtime behavior, which you influence only through the configuration.
Topics
A topic is an area of responsibility. It groups the instructions and actions needed for one kind of request. An agent usually has several topics, for example order support, returns, and product questions.
A topic has these fields:
- A classification description, which tells the agent what kinds of requests belong to the topic.
- A scope, which states what the topic does and does not do.
- Instructions, which guide behavior inside the topic.
- A list of actions the agent may use while in the topic.
Instructions
Instructions are plain-language rules, such as "Ask for the order number if the customer has not given one." They shape how the agent behaves after it has chosen a topic. They can require a step, forbid a behavior, or say when to call a particular action.
Actions
An action is something the agent can actually do. Without actions, an agent can only talk. With them, it can look up a record, update data, send a message, or generate a summary. Actions are backed by existing Salesforce automation: Flows, Apex invocable methods, prompt templates, and other types. The chapter on action types covers these.
A complete topic example
The following definition shows all four topic fields for a simple order support topic. It is written as plain text because Agentforce topics are configured in Setup. The structure is what matters.
Topic: Order Support
Classification description: Handles customer questions about the status of an existing order, such as where it is or when it will arrive.
Scope: Look up order status and explain it. Does not process returns, refunds, or changes to an order.
Instructions:
- Ask for the order number if the customer has not given one.
- Use the order status action to look up the order before answering.
- If the order cannot be found, say so and do not guess.
Actions: Get Order StatusRead it as the agent would:
- The classification description helps the agent decide whether a request such as "Where is my package?" belongs here.
- The scope draws a boundary. A request to refund an order is outside it.
- The instructions say what to do once inside, including what to do when the lookup fails.
- The action list limits what the agent can run in this topic.
How an agent handles one request
At a high level, every request goes through the same sequence. The reasoning loop chapter covers it fully. This is the overview.
Two decisions happen in this path:
- Topic selection. The engine compares the request to the classification descriptions of all topics and picks the best fit.
- Action selection. Inside the chosen topic, the engine reads the instructions and the available actions, then decides which action to call and what values to pass in.
The second decision depends on the first. An action that is not listed in the selected topic is not a candidate. This is the main way topics constrain an agent.
An action the agent can read
The agent chooses actions based on text. For an Apex action, that text comes from annotations on the method and its variables. The class below can be added to an agent as the Get Order Status action used in the topic above.
public with sharing class OrderStatusAction {
public class Request {
@InvocableVariable(label='Order Number' description='The order number the customer provided' required=true)
public String orderNumber;
}
public class Response {
@InvocableVariable(label='Status' description='Current status of the order, or Not Found')
public String status;
}
@InvocableMethod(label='Get Order Status' description='Looks up the current status of an order by its order number')
public static List<Response> getStatus(List<Request> requests) {
Set<String> orderNumbers = new Set<String>();
for (Request r : requests) {
orderNumbers.add(r.orderNumber);
}
Map<String, String> statusByNumber = new Map<String, String>();
for (Order o : [SELECT OrderNumber, Status FROM Order WHERE OrderNumber IN :orderNumbers]) {
statusByNumber.put(o.OrderNumber, o.Status);
}
List<Response> results = new List<Response>();
for (Request r : requests) {
Response res = new Response();
res.status = statusByNumber.containsKey(r.orderNumber) ? statusByNumber.get(r.orderNumber) : 'Not Found';
results.add(res);
}
return results;
}
}Points to notice:
- The method label,
Get Order Status, matches the name in the topic's action list. The method description tells the agent what the action does. - The
descriptiononorderNumbertells the agent what value to pass in. The agent extracts it from the conversation or asks the user for it. - The method accepts a list and returns a list. This is the standard invocable method pattern and lets Salesforce call it in bulk.
- The query runs once for all requests, not once per request, so it stays within governor limits.
- When no order matches, the method returns
Not Foundinstead of failing. The topic instruction "If the order cannot be found, say so and do not guess" can then act on that value. - The class uses
with sharing, so the query respects the running user's record access.
Why the design works this way
Splitting an agent into topics, instructions, and actions has practical effects.
- Smaller decisions. The engine first narrows to a topic, then chooses among that topic's actions. Choosing among five actions is easier and more reliable than choosing among fifty.
- Boundaries. A scope statement and a limited action list keep the agent from attempting work you did not intend. An order support topic with no refund action cannot issue a refund.
- Reuse of existing work. Actions wrap Flows and Apex you may already have, so the agent adds a natural-language front end to automation that is tested and governed.
- Editable behavior. Changing how the agent behaves often means editing text, not deploying code.
Common mistakes at this stage
- Treating descriptions as comments. The model reads them. A vague description such as "Gets data" gives the engine nothing to match against a request.
- Overlapping topics. If two classification descriptions describe nearly the same requests, the engine may pick the wrong one.
- Putting everything in one topic. A topic with many unrelated actions makes action selection harder.
- Expecting deterministic behavior. The same request may be phrased or handled slightly differently across runs. Testing, covered in a later chapter, is how you build confidence.
- Assuming instructions are enforced like code. Instructions guide an LLM. They are strong guidance but not a guarantee, which is why scope, action lists, and the Trust Layer exist as additional controls.
What comes next
The next chapter looks at the reasoning engine, the LLM-backed component that reads your configuration and makes the decisions described here. Later chapters then cover topic classification, instructions, action types, and how to trace a decision when the agent chooses wrongly.
Check your understanding
Exercise
A topic lists only the action Get Order Status. A customer asks the agent to refund an order, and the request is routed to this topic. Can the agent issue the refund, and which two parts of the topic definition work against it?
Show answer
No. The topic's action list contains no refund action, so the agent has nothing it can run to issue one. The scope also states that the topic does not process returns, refunds, or changes to an order. Together, the limited action list and the scope keep the agent inside its intended responsibility.
Exercise
In the Apex class above, why does the orderNumber variable have a description when the field name already says what it holds?
Show answer
The agent reads the description as text when deciding what value to pass into the action. A field name alone is thin context. The description states that this is the order number the customer provided, so the agent can pull it from the conversation or ask the user for it.
Exercise
Name the two decisions the reasoning engine makes for each request, and say which one depends on the other.
Show answer
First it selects a topic, then it selects an action within that topic. Action selection depends on topic selection, because only the actions listed in the chosen topic are candidates.