Sub topic 1
What Agentforce is and how its pieces fit together
Agentforce is Salesforce's platform for building AI agents that work inside your org. An agent reads a user's request, decides what to do, runs actions against your data and logic, and replies in natural language. This chapter gives you the working model. Later chapters set up the org and build the agent, and this one explains what each piece does and how the pieces connect.
Prerequisites
This chapter assumes you already know:
- Basic Salesforce concepts: objects, records, and the Setup menu.
- Lightning Experience, the current Salesforce interface.
- How to read a short Apex class. You only need this for the custom action example later in the tutorial, and this chapter does not require it.
You do not need an org yet. The next chapter covers sign-up. You also do not need the Salesforce CLI for this chapter. It appears later, in the optional deployment steps.
The working model in one paragraph
An agent is a configured set of topics. Each topic has a scope, a set of instructions, and a list of actions. When a user sends a message, the agent's reasoning engine picks the topic that fits. It follows that topic's instructions to choose actions, runs them, and writes a reply from the results. Every call to the underlying large language model (LLM) passes through the Einstein Trust Layer. Salesforce provides this layer so that your data is handled under controls you can review.
The names matter, so here is each one in turn.
| Piece | What it is | Where you configure it |
|---|---|---|
| Agent | The assistant as a whole, with a name, a role, a company description, and an assigned user | Agentforce Builder |
| Topic | A category of work the agent can handle, with a scope and instructions | Agentforce Builder |
| Instruction | A plain-language rule that tells the agent how to behave inside a topic | Inside the topic |
| Action | A unit of work the agent can run, such as querying records or calling Apex | Attached to a topic |
| Einstein Trust Layer | Controls applied to prompts and responses around the LLM call | Setup, with some settings admins can change |
How a request flows through an agent
The flow below shows one user message from arrival to reply.
Two points in this flow cause most beginner confusion.
First, the topic is chosen before any action runs. The reasoning engine compares the user's message with the descriptions of your topics. If your topic descriptions overlap, the engine can pick the wrong one. Write each description so it is clearly different from the others.
Second, the LLM does not query your database directly. It picks actions, and the actions touch data. Your sharing rules, field-level security, and Apex code still decide what is returned. The LLM sees only what the actions give back.
Topics and instructions
A topic limits the agent. It has three parts:
- A name and a description. The reasoning engine reads the description to decide whether the topic matches the message.
- A scope, which states what the topic does and what it does not do.
- Instructions, which are numbered rules the agent follows once the topic is selected.
Here is a sample topic definition. It uses the same case-status example the tutorial builds on later.
Topic: Case Status Questions
Description: Answer questions about the status of a customer's support cases.
Instructions:
1. Ask for the account if the user has not named one.
2. Use the Get Open Case Count action to look up the number of open cases.
3. Report the number in one sentence. Do not guess when the action returns no result.
4. If the user asks about anything other than case status, say you cannot help with that.Look at how the instructions are written. Each one is a single, checkable rule. Instruction 2 names the action. Instruction 3 says what to do when the action fails. Instruction 4 sets a boundary. Instructions like "be helpful and accurate" give the engine nothing to follow, so they rarely change behavior.
Actions
An action is what the agent does when it needs more than conversation. Agentforce supports several kinds:
- Standard actions that Salesforce provides, such as answering questions from knowledge or querying and summarizing records.
- Apex actions, which expose an invocable Apex method.
- Flow actions, which run an autolaunched flow.
- Prompt template actions, which call a template built in Prompt Builder.
Each action has defined inputs and outputs, and the agent fills the inputs from the conversation. The action's name and description guide the engine's choice, so they work like instructions. A custom action called "Get Open Case Count" with the description "Returns the number of open cases for an account" tells the engine what the action is for and when it applies.
This tutorial covers standard actions first, then Apex, then prompt templates. Apex actions need a deployed class, and the optional CLI steps handle that.
The Einstein Trust Layer
The Trust Layer sits between your org and the LLM. It does not change what your agent is. It changes what happens to a prompt on the way out and to a response on the way back. Its documented functions include:
- Grounding, which adds relevant record or knowledge data to the prompt so the answer rests on your data and not on the model's general training.
- Data masking, which replaces certain sensitive values with placeholders before the prompt leaves Salesforce, then restores them in the response.
- Zero data retention, a contractual arrangement with the model providers so they do not store your prompts or responses.
- Toxicity detection, which scores responses for harmful content.
- Audit trail, a record of prompts and responses that you can review.
A later chapter covers what each control does to your prompts. For now, keep one rule in mind. Masking applies to the data types and fields the Trust Layer is configured to recognize. Do not assume that every sensitive value in free text is caught.
Where Data Cloud fits
Agentforce setup in a Developer Edition org involves Data Cloud. In the setup flow you will see Data Cloud provisioned, and some features depend on it. Treat it as a platform dependency for Agentforce in this tutorial. You do not need to load external data into it to build the agent in this tutorial. A later chapter explains the dependency and what to do when provisioning is slow.
Where this tutorial goes
The chapters follow a build order. Each step depends on the one before it.
- Sign up for a Developer Edition org that includes Agentforce.
- Turn on Agentforce and generative AI in Setup.
- Assign permission sets so you can build and test agents.
- Create an agent in Agentforce Builder and give it topics, instructions, and standard actions.
- Add a custom Apex action and, optionally, a prompt template action.
- Test in the conversation preview, then activate.
- Learn what a Developer Edition org cannot do, and how to fix common setup problems.
The optional CLI steps use two commands. You will meet them again when you deploy the Apex class.
sf org login web --alias agentforce-dev
sf project deploy start --source-dir force-app --target-org agentforce-devThe first command logs the CLI in to your org under the alias agentforce-dev. The second deploys the local force-app directory to that org.
Common misunderstandings
These errors come up often when people start with Agentforce.
- Treating instructions as code. Instructions guide a language model. They are not a program. The same input can occasionally produce different wording, so test several phrasings of each request.
- Overlapping topics. If two topic descriptions both mention "orders," the engine may pick either. Narrow each scope and name what each topic excludes.
- Expecting the agent to see everything. The agent works through its actions and the permissions of its running user. If a record is hidden from that user, the agent cannot read it.
- Putting the whole job in one topic. A topic with ten actions and long instructions is harder to steer than three small topics.
- Assuming production features exist in Developer Edition. Some channels and limits differ in a Developer Edition org. The final chapter covers them, so check it before you plan a demo around a channel.
Check your understanding
Exercise
A user asks your agent about a refund policy, but the agent answers using your "Case Status Questions" topic. Name two causes related to how topics are selected and one fix for each.
Show answer
First cause: the topic descriptions overlap, so the reasoning engine cannot tell the topics apart. Fix: rewrite each description so it names a distinct task and, where useful, says what the topic does not cover. Second cause: no topic covers refund policy, so the engine falls back to the closest match. Fix: add a topic for refund questions, or add an instruction to the existing topic telling the agent to say it cannot help with anything other than case status.
Exercise
The LLM never queries your database directly. Explain what does, and why that matters for security.
Show answer
Actions query the data. They are standard actions, Apex methods, flows, or prompt templates, and they run with the access of the agent's assigned user plus your sharing rules and field-level security. This matters because the model can only reason over what the actions return, so limiting the user's access and the action's output limits what the agent can reveal.