Sub topic 3
What a Topic Is and Why Agents Need Them
This chapter assumes you know basic Salesforce concepts (objects, fields, records), can find your way around Setup, and have a general idea of what a large language model (LLM) does. You don't need to write Flow or Apex yet. Later chapters cover the parts of a topic in detail. This chapter explains what a topic is and why an agent can't work well without them.
The problem topics solve
An Agentforce agent receives free-form text from a user. A customer might write "where's my stuff?", "I want my money back", or "can you help me pick a laptop?". The agent has to decide what kind of request each one is, what rules apply, and which tools it may use.
Without structure, you would give the LLM every instruction and every action at once. This causes three problems:
- Crowded context. The LLM reads all the instructions on every turn. Instructions for returns can distract it while it answers a shipping question.
- Wrong tool choice. If the agent can see twenty actions, it is more likely to pick one that is close but wrong, such as a refund action for a status question.
- Hard maintenance. When behavior changes, you can't tell which instruction caused it.
A topic solves this by grouping one job with everything needed to do that job. The agent first picks a topic, then works only with that topic's instructions and actions.
What a topic contains
A topic is a unit of work that an agent can recognize and handle. Each topic has four parts.
| Part | What it is | What it does |
|---|---|---|
| Name | A short label, such as Order Status | Helps the agent and you identify the topic |
| Classification description | A sentence or two saying which requests belong here | Used to match an incoming request to this topic |
| Scope | A statement of what the agent does and does not do inside the topic | Sets the boundary of the job |
| Instructions and actions | Natural-language guidance plus the actions the agent may invoke | Guide reasoning and let the agent read or change data |
The name and classification description answer the question "Is this request mine?". The scope, instructions, and actions answer the question "Now that it is mine, what do I do?". Chapters 4 to 6 cover each part in turn.
How a request reaches a topic
When a user sends a message, the agent's reasoning engine works in stages. It reads the message and the conversation so far, compares them with the name and classification description of each topic, and picks the best match. Only then does it load that topic's scope, instructions, and actions. It then chooses actions, runs them, and writes a reply.
Two points follow from this sequence:
- Selection happens before instructions are read. If the classification description is vague, the agent can pick the wrong topic, and no instruction inside the right topic will help. Classification is the first place to look when a request lands in the wrong place.
- A topic limits what the agent can do on that turn. The agent can only use actions that belong to the selected topic. This is useful. A topic with only read actions cannot change data, whatever the user asks.
Topic selection is not a one-time decision. The agent reconsiders it as the conversation continues, so a customer who asks about an order and then about a return can move between topics.
A worked example: two topics side by side
Suppose you build a service agent for an online shop. You start with two jobs, checking order status and handling returns. Here is how the first topic might look in plain text.
Topic name: Order Status
Classification description:
Handle customer questions about where an existing order is and what its current status is. Do not use for returns, refunds, or new orders.
Scope:
Your job is to look up the status of an existing order and report it. You cannot change or cancel orders.
Instructions:
1. Ask the customer for their order number if they have not given one.
2. Use the Get Order Status action with that order number.
3. If the action returns 'Not found', tell the customer you could not find the order and ask them to check the number.
4. Otherwise, state the status in one sentence.
5. Never share details about orders that belong to other customers.
Actions:
- Get Order StatusThe classification description says what the topic handles and also what it does not handle. The scope sets a limit: the agent can report a status but can't cancel an order. The instructions are short ordered steps that you can check against a test conversation. The topic has a single action, so the agent has little chance of picking the wrong one.
A second topic, Returns, would have its own description, instructions, and actions (for example, one that creates a return case). Compare how the same message behaves with and without topics:
| User message | Without topics | With Order Status and Returns topics |
|---|---|---|
| "Where is order 10045?" | The agent weighs all instructions and all actions together | The agent selects Order Status and uses Get Order Status |
| "I want to send order 10045 back" | The agent might answer with the order status, because the order number appears in the message | The agent selects Returns, because the request is a return, whatever the order number |
| "Cancel order 10045" | The agent might attempt something no action supports | Order Status is the closest topic, but its scope says it cannot cancel, so the agent says so |
The third row shows what scope is for. Even when the agent picks the closest topic, the scope tells it where to stop instead of improvising.
Why not one large topic?
It is tempting to build a single topic called "Customer Service" with every instruction and action. This works in a demo and tends to fail in production, for these reasons:
- Instruction conflicts. "Always ask for the order number first" suits order lookups but not a general product question. In one large topic, rules like this compete.
- Too many actions. More actions give the agent more ways to choose wrongly.
- Weak classification. A description that covers everything gives the agent nothing to separate one request from another.
- Poor testing. You can't test a job in isolation if it shares instructions with every other job.
The opposite mistake is a topic for every tiny variation, such as "Order Status by Email" and "Order Status by Phone". Topics with overlapping descriptions compete for the same requests, and the agent may switch between them unpredictably. A good guideline is to make one topic per job that a human agent would recognize as separate, with different rules and different tools.
Common errors
These are the mistakes people make most often when they first create topics.
- Describing the topic by its name only. A description such as "Orders" matches too much. Say what the customer is trying to do, and name the neighboring jobs it excludes.
- Overlapping descriptions. If two topics could both claim "I need help with my order", the agent will split those requests between them. Test with ambiguous phrases and tighten the descriptions.
- Putting classification rules in the instructions. Instructions are read after the topic is chosen. Text that says "use this topic when..." belongs in the classification description.
- Giving a topic actions it should never use. If a read-only topic includes an action that updates records, a mistaken or manipulated conversation can reach that action. Add only what the job requires.
- Skipping the out-of-scope case. Decide what the agent should say when the user asks for something the topic can't do. If you don't, the agent may guess.
What you can check yourself
In Agentforce Builder you can test a message and see which topic the agent picked. Treat that as the first check on any change. If the topic is wrong, fix the name or classification description. If the topic is right but the reply is wrong, look at the scope, instructions, and actions. The testing chapter shows this loop in detail.
Exercise
A customer writes "Can I send back the shoes from order 20311?" The agent replies with the order's shipping status. The Order Status topic contains correct instructions and a working Get Order Status action. What is the most likely cause, and where should you fix it first?
Show answer
The agent selected the Order Status topic instead of a Returns topic, probably because the message contains an order number and the classification descriptions overlap or the Returns description is too vague. The instructions inside Order Status are not the problem, because topic selection happens before they are read. Fix the classification descriptions first: make Order Status exclude returns (it already says "Do not use for returns") and make the Returns description state that it handles requests to send items back. Then retest the same message in Builder.
Exercise
Name two reasons to give a topic only the actions its job requires.
Show answer
First, fewer actions means fewer chances for the agent to pick a similar but wrong action. Second, a topic limits what the agent can do on that turn, so a read-only topic cannot change data even if a user asks it to. Both reduce risk and make the topic easier to test.