Sub topic 3
What a Topic Is and Why Agents Need Them
This chapter assumes you know basic Salesforce concepts (objects, fields, records), have used Setup, and have a general idea of what a large language model (LLM) does. Flow or Apex knowledge helps later but is not needed here.
The problem topics solve
An agent receives free-form text. A customer might write "where's my stuff?" or "I want my money back." The agent needs a way to decide which job the message belongs to before it can act.
A topic is a category of jobs the agent can handle. Each topic bundles three things:
- A classification description, which tells the agent when a request belongs to this topic.
- A scope, which says what the topic does and where its job ends.
- Instructions and actions, which tell the agent how to reason and what it can do once the topic is chosen.
Without topics, the agent would have every instruction and every action available for every message. That makes it slower, less predictable, and more likely to call the wrong action.
How a topic is chosen
The agent's reasoning engine reads the user's message, then compares it against the name and classification description of each topic. It selects the best match. Only that topic's instructions and actions are then used to build the response.
Because selection depends on the text you write, the quality of a topic's name and description directly affects routing. The next chapter covers how to write them.
Anatomy of a topic
Here is a small topic definition for order lookups.
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.Each part has a different job:
| Part | Question it answers | Used when |
|---|---|---|
| Name | What is this topic called? | Identifying the topic, and as a signal during selection |
| Classification description | Does this request belong here? | The agent chooses a topic |
| Scope | What may the agent do here, and what is off limits? | The agent is working inside the topic |
| Instructions | How should the agent proceed? | The agent is working inside the topic |
| Actions | What can the agent actually do? | The agent needs to read or change data |
Notice that the description above states what the topic handles and what it excludes. The exclusion ("Do not use for returns, refunds, or new orders") helps the agent separate this topic from neighboring ones.
Why one topic per job
A topic should cover one coherent job. Two common mistakes cause trouble:
- Too broad. A topic named "Customer Service" that covers orders, returns, billing, and account changes. The description matches nearly everything, so it overlaps with other topics, and its long instruction list becomes hard to follow.
- Too narrow. A separate topic for every phrasing of a question. The agent must choose between near-identical options, and you maintain many copies of similar instructions.
A good test is whether you can describe the job in one or two sentences without using "and" to join unrelated tasks.
Common errors
- Overlapping descriptions. If two topics both claim "questions about orders," the agent may pick either one. Add explicit exclusions to each.
- Putting step-by-step logic in the description. The description is for classification. Put the steps in instructions.
- Assuming the topic limits permissions. A topic guides behavior, but it does not secure data. Enforce access in the actions themselves, for example with user-mode queries in Apex.
Exercise
A topic named "Customer Help" has the description "Answer customer questions." Users asking about refunds sometimes get order status answers. Name two problems with this design and one fix.
Show answer
The topic is too broad, and its description is too vague to separate order questions from refund questions. A fix is to split it into focused topics such as Order Status and Refunds, each with a description that states what it handles and what it excludes.