Sub topic 3
Topics: the agent's areas of responsibility
This chapter assumes you know what an Agentforce agent is at a high level. It also assumes you can find Setup and the agent builder, and that you know an action is something an agent can run, such as a Flow or Apex method. The chapter covers what a topic is, what it contains, how to draw its boundaries, and the mistakes that most often break agents.
What a topic is
A topic is a bounded area of responsibility inside an agent. Each topic groups together three things:
- The kind of request it handles.
- The rules the agent follows while handling it.
- The actions the agent may use to do the work.
An agent is a set of topics plus the reasoning engine that picks between them. When a user message arrives, the agent first decides which topic the message belongs to. Everything after that happens inside that topic. The agent reads that topic's instructions and chooses only among that topic's actions.
This makes the topic a filter as well as a label. An action that is not attached to the active topic is not a candidate for that turn. The agent cannot call it, no matter how well its description fits the request. Topics therefore limit what the agent can do at any moment, and that is the main reason to split an agent into several of them.
The parts of a topic
A topic is defined by five parts. The first two are read mainly when the agent chooses a topic. The last three are read after the topic is chosen.
| Part | Purpose | Read when |
|---|---|---|
| Name | A short label for the topic. | Selecting a topic, and when you read traces. |
| Classification description | Says what kinds of requests belong here. | Selecting a topic. |
| Scope | States what the topic does and does not do. | Working inside the topic. |
| Instructions | Rules for how to behave and when to use which action. | Working inside the topic. |
| Actions | The things the agent can run. | Choosing an action. |
Later chapters cover classification, instructions, and actions in detail. Here the goal is to see how the parts divide the work.
Here is a complete topic written out as plain text:
Topic: Order Support
Classification description: Handles customer questions about the status of an existing order, such as where it is or when it will arrive.
Scope: Look up order status and explain it. Does not process returns, refunds, or changes to an order.
Instructions:
- Ask for the order number if the customer has not given one.
- Use the order status action to look up the order before answering.
- If the order cannot be found, say so and do not guess.
Actions: Get Order StatusEach part does a different job:
- The classification description is written from the point of view of a request: "questions about the status of an existing order." It describes what a user might say.
- The scope is written from the point of view of the agent's behavior. It names what the agent will do and, just as important, what it will not do.
- The instructions are the working rules. They say what to ask for, which action to call first, and what to do on failure.
- The action list is the only set of tools available once the topic is active.
Why split an agent into topics
You could put every instruction and every action into one large topic. That works for a demo and fails as the agent grows, for three reasons.
- Instruction crowding. The agent reads the active topic's instructions each turn. With forty instructions, rules for unrelated tasks compete for attention. Rules about refunds can leak into an order status conversation.
- Action crowding. The more actions are available, the more chances there are for the agent to pick a plausible but wrong one. Two actions with similar descriptions are harder to tell apart than one.
- Weak control. If refunds and status lookups share a topic, you cannot allow one and block the other. Separate topics give you a boundary you can reason about.
Topics are also the unit you test and change. When a conversation goes wrong, you can ask which topic was chosen, then whether that was right. A narrow topic gives you a much smaller area to inspect than one huge topic.
Drawing topic boundaries
Boundaries work best when they follow what the user is trying to get done, not your org's objects or teams. "Order Support" is a good topic. "Order object operations" is not, because users do not ask for object operations.
Some practical rules:
- One job per topic. If the classification description needs the word "and" to join unrelated jobs, consider two topics.
- Group actions that share instructions. If two actions need the same rules, such as "always confirm the order number first," they likely belong together.
- Separate read from write. A topic that only looks things up is safer than one that also changes records. Putting refunds in their own topic lets you give them stricter instructions.
- Do not duplicate actions across topics without a reason. The same action can be attached to more than one topic. Do this deliberately, because it makes traces harder to read.
- Plan for requests that fit nowhere. Agents need a place to send out-of-scope questions, often with a polite refusal or a handoff to a person. Agentforce provides standard topics for cases like this, such as escalation and off-topic handling. Check which ones your org offers and what they do before writing your own.
The tradeoff is topic count. Too few topics give you the crowding problems above. Too many topics make topic selection harder, because the descriptions start to overlap and the agent has more near-matches to choose between. A reasonable aim is topics whose descriptions you could not confuse with each other when reading them cold.
Common errors
Overlapping classification descriptions
Suppose "Order Support" says "questions about orders" and "Returns" says "questions about orders that need to be sent back." A message such as "I have a problem with my order" fits both. The agent may pick either, and may pick differently from one run to the next.
Fix the overlap by making each description state what is distinct. Use the scope to say what each topic excludes. Make sure that a message that truly fits both is handled by an instruction, such as asking the user a clarifying question.
A scope that says only what the topic does
A scope such as "Look up order status" says nothing about refunds. When a user asks for one in the middle of an order conversation, the agent has no stated limit, so it may try to improvise. State the exclusions: "Does not process returns, refunds, or changes to an order." Stated limits give the agent something to apply when a request drifts.
Missing actions
The topic's instructions say "look up the order," but no lookup action is attached to the topic. The agent cannot call an action that is not in the topic, so it will answer from nothing or describe a step it cannot perform. When an agent claims to have done something it never did, check the topic's action list first.
Instructions that belong in another topic
A rule like "if the customer wants a refund, collect the reason and call Create Refund" sitting inside Order Support pulls refund behavior into a topic that has no refund action. Move rules for a task into the topic that owns that task.
Topics written for administrators, not for the agent
The agent reads the text of the topic. Internal jargon, ticket numbers, and references such as "see the wiki" mean nothing to it. Write descriptions and instructions as plain statements of fact about the user's request and the agent's behavior.
A worked boundary check
Take a retail agent with these three topics: Order Support, Returns, and Store Hours FAQ. Check how four messages would be routed:
- "Where is order 10442?" matches Order Support. It is a status question about an existing order.
- "I want to send back my shoes." matches Returns, since the user wants to start a return. Order Support's scope excludes this explicitly.
- "What time do you close on Sunday?" matches Store Hours FAQ.
- "Can you write me a poem?" matches none. A well-designed agent has a defined response, such as a polite statement that it cannot help with that.
The fourth message shows why boundaries are a design task. If no topic or standard behavior covers it, the outcome depends on whichever topic looks least wrong.
Summary of the working model
- An agent has several topics, and each turn is handled inside one of them.
- A topic holds a classification description, a scope, instructions, and a list of actions.
- The topic limits both the rules in force and the actions that can run.
- Good topics follow user goals, have distinct descriptions, and state what they exclude.
- Most topic bugs come from overlapping descriptions, vague scope, or actions missing from the list.
Exercise
A customer writes "I want to change the delivery address on my order." Your agent has an Order Support topic whose scope reads "Look up order status and explain it," and a Returns topic. The agent tries to answer the request using Order Support, and it says the address was changed, but no record was updated. Give two likely causes in the topic design and one fix for each.
Show answer
First cause: the scope of Order Support does not exclude changes to an order, so the agent has no stated limit and improvises a reply. Fix: add "Does not process returns, refunds, or changes to an order" to the scope, and add an instruction on what to say or where to send the user for address changes. Second cause: no action that updates the address is attached to the topic, so the agent cannot actually perform the change and only describes it. Fix: either create a dedicated topic with an address update action and a classification description that matches such requests, or leave it out and have the agent hand off to a person. Either way, make sure instructions never claim a step that no attached action can carry out.
Exercise
Two topics have these classification descriptions. Topic A: "Questions about orders." Topic B: "Questions about orders that the customer wants to return." Rewrite them so that a message such as "Where is my order?" clearly belongs to only one.
Show answer
Topic A: "Questions about the status or delivery of an existing order, such as where it is or when it will arrive." Topic B: "Requests to send back or exchange items from a delivered order, such as starting a return or asking about return eligibility." The rewrite puts the distinguishing intent in each description (status versus returning), so "Where is my order?" matches only Topic A. Adding an exclusion to each topic's scope, for example "Does not handle returns" in Topic A, makes the boundary stronger.