Sub topic 1
What an Agentforce agent is made of
An Agentforce agent is a configured set of instructions and capabilities that an AI model uses to handle a conversation inside your Salesforce org. Before you create one with the CLI, you need to know its parts. The spec file, the tests, and the metadata you commit later all describe these same parts.
Prerequisites
This chapter assumes you have:
- Basic command-line use.
- Familiarity with Salesforce orgs, sandboxes, and scratch orgs.
- A basic understanding of Apex or Flow.
You don't need the Salesforce CLI installed yet. The next chapter covers setup.
The working model
An agent is built from four layers.
- Agent definition. The agent's name, role, company description, and type. The role is a plain-language statement of what the agent is for, such as "Answer questions about the status of customer support cases."
- Topics. A topic is a category of work the agent can do. Each topic has a description, a scope, and instructions. The description is what the model reads to decide whether a user's request belongs to the topic.
- Instructions. Natural-language rules inside a topic. They tell the agent how to behave, for example "Ask for the case number if the user hasn't given one."
- Actions. The things the agent can do. An action runs real logic, such as querying records or calling a service, and returns a result to the conversation.
How a request flows
When a user sends an utterance (one message), the agent first picks a topic. Inside that topic, it follows the instructions and decides which actions to call. It then writes a reply from the action results.
The model chooses topics and actions by reading text. It does not match keywords. The wording of your descriptions therefore decides how the agent behaves.
Kinds of actions
Actions can be backed by different implementations.
| Backing | Typical use |
|---|---|
| Invocable Apex | Custom logic, such as looking up a case by number |
| Flow | Declarative automation that already exists in your org |
| Prompt template | Generating text from record data |
| Standard action | Built-in capabilities that ship with Agentforce |
Later chapters cover topics and action types in more detail and build an Apex-backed action.
Why this matters for the CLI
The Setup UI hides the structure behind forms. The CLI exposes it. You describe the role and topics in a spec file, the CLI creates the agent from it, and the pieces become metadata in your DX project. The metadata includes the agent (Bot and BotVersion), topics (GenAiPlugin), and actions (GenAiFunction). Because of this, you can review changes in a pull request like any other code.
Common mistakes
- Vague topic descriptions. Two topics with overlapping descriptions cause the agent to pick the wrong one. Write each description so that it says what the topic covers and what it does not.
- Rules in the wrong place. Instructions that apply to one task belong in that topic, not in the agent's role.
- Unclear action descriptions. The model decides when to call an action from its label and description. An action named
Processwith no description is rarely called correctly. - Expecting deterministic output. The same utterance can produce different wording. Test for the topic, the actions, and the outcome, not for exact text.
Exercise
A user asks, "Where is my order?" and the agent answers with details from the wrong topic. Which part of the agent's definition should you inspect first, and why?
Show answer
Inspect the topic descriptions. The agent picks a topic by reading each description and comparing it to the utterance. If two descriptions overlap, or the intended topic's description doesn't mention orders, the agent can choose the wrong topic. Fix the descriptions before changing instructions or actions.