Sub topic 7
Scoping an agent with topics
This chapter assumes you know what an Agentforce agent is, what a topic and an action are, and how permission sets work. You should also know that the agent user's permissions (covered in earlier chapters) set the data ceiling. Here you will see how topics set the behavior boundary beneath that ceiling.
What a topic is
A topic is a named area of work that the agent can take on. Each topic bundles four things:
| Part | Purpose |
|---|---|
| Name | A short label for the job, such as "Order Status". |
| Classification description | Tells the agent's reasoning engine when a customer message belongs to this topic. |
| Scope | States what the topic does and, just as important, what it does not do. |
| Instructions | Rules for how the agent behaves once the topic is active. |
| Actions | The only operations the agent can run while in this topic. |
When a message arrives, the reasoning engine compares it with the classification description of every topic. It picks the best match. From then on, the agent sees only that topic's instructions and actions. Everything else is out of view for that turn.
This makes a topic a scope boundary. A customer who asks about order status never gives the model the chance to call a refund action, because no refund action exists in the Order Status topic.
Topics limit behavior, not access
A topic does not change what the agent user can read or write. If the agent user has the Delete permission on Order, a mistake in routing or instructions could still expose that power. Topics reduce the chance that the agent reaches for a capability. Permission sets, sharing, field-level security, and user-mode Apex are what stop it from using one.
Think of the two layers as a pair:
- Permissions decide what is possible for the agent user.
- Topics decide what the agent is meant to do with that access.
You need both. Permissions without topics give an agent that can do a lot and wanders. Topics without permissions give a well-behaved agent sitting on far more access than it needs.
Writing the classification description
The classification description is the routing signal. It is the most common source of scoping errors. A good one is specific about the customer's intent, not just the subject area.
Weak:
- "Orders."
- "Handles customer questions."
Stronger:
- "Customer asks where their order is, whether it shipped, or what its current status is. Does not cover returns, refunds, or changes to an order."
Guidelines:
- Describe what the customer is trying to do, in the words a customer would use.
- Name the boundary. If a neighboring topic handles refunds, say that this topic does not.
- Keep one topic to one job. If the description needs the word "or" between unrelated tasks, split it.
- Avoid overlap. When two descriptions both fit a message, routing becomes unpredictable.
Writing the scope
Scope is a plain-language statement of the topic's job and limits. It works with the classification description but serves a different purpose. The classification description decides whether the topic is chosen. The scope tells the model what to do once it is inside.
For the Order Status topic, a scope might read: "Your job is to tell customers the current status of their own orders. You do not process returns, refunds, price changes, or account changes."
Keep scope statements short and concrete. A paragraph of general goals gives the model room to improvise, and improvisation is what you are trying to remove.
Instructions inside a topic
Topic instructions are the rules the agent follows while the topic is active. The next chapter covers how to write them well. For now, notice how they relate to scope. Scope says what the topic is for. Instructions say what to do and what to refuse in specific situations.
Here is a sample set of instructions for the Order Status topic:
Only answer questions about the status of the customer's own orders.
Never share information about other customers.
Never offer refunds, price changes, or account changes. If the customer asks for one, tell them you are transferring them to a human agent.
If you cannot find the order, say so and ask the customer to confirm the order number.Each line is short, specific, and testable. You can write a test message for every rule.
Assigning actions to topics
Actions give a topic the ability to act. Every action you attach to a topic is a capability the model can choose to use whenever that topic is active. Two habits keep this safe:
- Attach only the actions the topic's job requires. Order Status needs a read action for status. It does not need an action that updates an order.
- Prefer several narrow topics over one broad topic with many actions. A narrow topic exposes a small set of actions. A broad topic exposes all of them at once.
Action design has its own chapter. For scoping, remember that the action list is part of the boundary. Adding an action to a topic widens the boundary just as widening the scope text does.
Handling requests that fit no topic
Not every message belongs somewhere. Plan for the messages that do not.
- Off-topic messages. The agent should decline politely and say what it can help with. Agentforce provides standard handling for off-topic and ambiguous questions. Review its wording and adjust it to match your brand and your rules.
- Requests the agent must not fulfill. A refund request is on-topic for the business but out of bounds for this agent. Give it a home: an escalation topic that tells the customer a human will take over and triggers the handoff.
- Ambiguous messages. If a message could fit two topics, the agent should ask a clarifying question instead of guessing.
Designing a topic set
A small service agent for order questions might use this layout:
| Topic | Customer intent | Actions | Boundary |
|---|---|---|---|
| Order Status | Find out where an order is | Get Order Status (read only) | No changes, no other customers' data |
| Escalation | Ask for a refund, a change, or a person | Transfer to human | No attempt to resolve the request itself |
| Off Topic | Anything unrelated | None | Decline and redirect |
The layout is deliberately small. Each topic has one job, and only Order Status touches data.
Common errors
- Topics that overlap. Two topics both claim "order questions", so routing flips between them. Fix by adding "does not cover" language to each description.
- A catch-all topic. A topic named "General Help" with many actions attracts most messages and exposes every action. Split it by intent.
- Scope that restates the topic name. "Handles orders" tells the model nothing about limits. Name what is excluded.
- Relying on instructions to compensate for excess actions. If the topic should never issue refunds, remove the refund action instead of writing "do not use the refund action".
- No escalation path. Customers whose requests the agent refuses have nowhere to go, and the agent may improvise to be helpful.
- Changing a topic without retesting. A small edit to a description can change routing for messages you never looked at. Rerun your test messages after each edit.
Checking your scope
Before moving on, send these kinds of messages to the agent and confirm the behavior:
- A clear in-scope request. The agent should pick the right topic and answer.
- A request for something just outside scope, such as a refund. The agent should refuse and escalate.
- A message about another customer's order. The agent should refuse, and the permission model should block the data even if the agent tries.
- An unrelated message. The agent should decline and redirect.
- An ambiguous message. The agent should ask a question.
If test 3 relies on instructions alone, you have a gap. The Apex and sharing chapters close it.
Exercise
An agent has one topic named "Customer Help" with the description "Answers customer questions" and ten actions, including a refund action. A customer asks for a refund and the agent issues it. Name two scoping changes that would prevent this, and explain why topic changes alone are not a complete fix.
Show answer
First, split "Customer Help" into narrow topics by intent, for example Order Status and Escalation, and give each a description that states what it does not cover. Second, remove the refund action from every topic that should not issue refunds, and route refund requests to an Escalation topic that transfers to a human. Topic changes are not a complete fix because topics and instructions steer a language model and can fail. The agent user's permission set should also deny the access the refund needs, so a routing mistake cannot complete a refund.
Exercise
Write a classification description for an "Order Status" topic that names its boundary against refunds.
Show answer
One valid answer: "Customer asks where their order is, whether it has shipped, or what its current status is. Does not cover returns, refunds, cancellations, or changes to an order." The description states the customer's intent in their own words and excludes the neighboring job that belongs to another topic.