Sub topic 1
How an Agentforce agent decides what to do
Prerequisites
This chapter assumes you know the basic Salesforce data model (objects, fields, records) and can move around Setup in Lightning Experience. You should also know in general terms what an AI agent and a large language model (LLM) are, and that permission sets and profiles control access to data. You don't need to have built an agent before.
The reasoning loop
An Agentforce agent is not a fixed script. It uses an LLM to read each user message, decide what the user wants, and pick the next step. The agent's configuration limits what the LLM can do. Three pieces make up that configuration:
- Topics group the work the agent can handle, such as account support.
- Instructions are plain-language rules inside a topic that say how to behave.
- Actions are the things the agent can actually do, such as querying records or sending an email.
The LLM only decides. Actions do the work against your Salesforce data.
What happens on each turn
For every user message, the agent runs roughly the same cycle.
- Classify. The agent compares the message and conversation so far against each topic's classification description. It selects the best match.
- Load scope. Only the selected topic's instructions and actions become available. Everything else is out of scope for this turn.
- Plan. Guided by the instructions, the LLM chooses an action, or decides to answer or ask a question.
- Act. The chosen action runs with inputs the agent filled from the conversation. The result returns to the LLM.
- Repeat or reply. The LLM may run another action using that result. When it has enough, it writes the reply.
Why topic wording matters
Classification relies on the topic's classification description, so a vague description sends messages to the wrong topic. The instructions then shape the plan. Compare the two parts in this example:
Topic: Account Support
Classification description:
Handle questions about a customer's account, such as looking up an account, summarizing it, or updating basic fields.
Instructions:
1. When the user names an account, first find the account record, then use the result for any later step.
2. Use the summary action when the user asks for an overview of an account.
3. Before updating a record, restate the field and the new value and ask the user to confirm.
4. If you cannot find exactly one matching record, ask the user to clarify instead of guessing.The description decides whether this topic is chosen. The instructions decide the order of actions, when to confirm, and when to ask the user instead of acting.
Common errors
- Overlapping topics. Two topics with similar descriptions make classification unreliable. Keep each one narrow and distinct.
- Missing ordering. If an action needs a record Id, say to find the record first. Otherwise the agent may try to guess.
- Expecting memory of data it never fetched. The agent only knows what the conversation and action results contain.
Exercise
A user asks "Summarize the Acme account." The agent replies with a general answer and runs no actions. Name two parts of the configuration you would check first.
Show answer
Check the topic's classification description, to confirm the message is routed to a topic that has account actions. Then check the topic's instructions and actions, to confirm a summary action is added and the instructions say when to use it.