Sub topic 5
Setting a Topic's Scope
This chapter assumes you know what a topic is and have seen the topic name and classification description fields in Agentforce Builder. You should also know that instructions and actions come after scope in the topic definition. Here you will learn what the scope field does, how it differs from the classification description, and how to write one that holds up in testing.
What scope is for
A topic has two pieces of text that look similar and do different jobs.
- The classification description helps the agent decide whether a customer request belongs to this topic.
- The scope tells the agent what its job is once the topic has been selected, and where that job ends.
The first is about routing. The second is about behavior inside the topic. If the classification description says "handle questions about order status," the scope says what handling means: look up the status and report it. It also says what the agent must not do, such as change or cancel an order.
Here is the example from this tutorial's topic definition:
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.The classification description names the requests that belong here and excludes neighbors. The scope is written to the agent ("Your job is..."). It states a positive duty and a hard limit.
Why scope matters
Selecting a topic does not guarantee that the request is a good fit. Customers write messages like "Where is my order, and can you cancel it if it's late?" The classification description may well send this to Order Status, because half of the message is about order status. Without a scope, the agent has no stated reason to refuse the second half. It may improvise, promise a cancellation it cannot perform, or call an action that was not designed for that purpose.
A clear scope gives you three things:
- A boundary for improvisation. The model fills gaps with plausible behavior. Scope narrows what counts as plausible.
- A stable reference for instructions. Instructions describe steps. Scope describes the purpose those steps serve. When a step is ambiguous, the agent can fall back on the purpose.
- A test target. You can write test messages that probe the edge of the scope and check that the agent stays inside it.
What a good scope contains
A useful scope usually has three parts. They can fit in two or three sentences.
- The job. One sentence that says what the agent does in this topic, using a verb.
- The limits. What the agent cannot do, stated as capabilities and not as topics. "You cannot change or cancel orders" is a capability limit.
- The data boundary, if one matters. For example, "Only discuss orders that belong to the customer you are talking to."
Compare two versions for the same topic.
| Version | Text | Problem or strength |
|---|---|---|
| Vague | "Help with orders." | Overlaps with returns, new orders, and billing. No limit stated. |
| Too broad | "Answer any question the customer has about their purchase experience." | Invites the agent to answer questions it has no action or data for. |
| Focused | "Your job is to look up the status of an existing order and report it. You cannot change or cancel orders." | One job, one explicit limit. |
The focused version is short. Scope is not a place for step-by-step procedure. If you find yourself writing "first ask for the order number, then call the action," move that text to the topic instructions, which have their own chapter.
Scope versus classification description
Because the two fields overlap, authors often copy the same sentence into both. That wastes the second field. Use this split:
| Field | Question it answers | Written as | Typical content |
|---|---|---|---|
| Classification description | Should this topic be chosen for this request? | A description of the requests that belong here | Request types, plus nearby types to exclude |
| Scope | What may the agent do once here? | Direct address to the agent | The job and the limits |
A request can be correctly classified and still partly out of scope, as in the cancel-if-late message above. The reverse is also possible. If the classification description is too narrow, a legitimate order status question may be routed elsewhere, and the scope never comes into play. When a test fails, check which of the two fields caused it before editing either one.
Scope and actions must agree
The scope is a promise about capability, so it has to match the actions attached to the topic. Two mismatches are common.
- Scope promises more than the actions deliver. If the scope says "help customers track and update orders" but the topic has only a Get Order Status action, the agent will tell customers it can update orders and then fail. Narrow the scope or add a suitable action.
- Actions can do more than the scope allows. Suppose you attach a Flow that can cancel orders to the Order Status topic for reuse. The scope says the agent cannot cancel, but the action makes it possible. The text and the tools now disagree, and the agent may follow the tool. Remove the action from this topic, or change the scope on purpose.
Scope text is guidance to the model, not an enforced permission. It reduces the chance of out-of-scope behavior but does not guarantee it. Anything that must never happen should also be prevented by what you attach: do not give the topic an action that performs it. The invocable Apex example in this tutorial runs its query with WITH USER_MODE, so field and object permissions apply even if the agent misbehaves. Treat scope as one layer of control, not the only one.
Handling out-of-scope requests
Decide in advance what the agent should do when a request falls outside the scope. There are usually three options:
- State the limit and stop. "I can check the status of an order, but I can't cancel it."
- Redirect to another topic. If a Returns topic exists, a request to return an item should have been classified there. Fix the classification description rather than adding return handling here.
- Hand off to a person. Useful where no topic covers the need.
Put the limit in the scope, and put the handling in the instructions. For example, scope says "You cannot change or cancel orders," and an instruction says "If the customer asks to change or cancel an order, say you cannot do that here and offer to connect them with support." Splitting it this way keeps each field easy to test. This assumes your agent has a hand-off path configured. If it does not, leave that sentence out, because the agent would offer something it cannot deliver.
Common errors
- Scope written as a topic list. "Orders, shipping, returns" describes subject matter and duplicates the classification description. Write a job and limits.
- Negative-only scope. A list of prohibitions with no stated job leaves the agent unsure what it should do.
- Limits phrased as topics. "Do not discuss refunds" is weaker than "You cannot issue or promise refunds." The second names the capability the customer is actually asking for.
- Scope that covers two jobs. If you need "and" to connect two different verbs, consider two topics. Distinct topics are easier to classify and test.
- Scope that was never tested. It reads well and fails on the first mixed request. Test it with messages that sit on the boundary.
Testing a scope
In Agentforce Builder, send messages that are designed to probe the scope, and read how the agent responds. For the Order Status topic, try:
1. "Where is order 10045?" (in scope, expect a status)
2. "Cancel order 10045." (out of scope, expect a stated limit)
3. "Where is order 10045, and cancel it if it's late." (mixed, expect the status plus a stated limit)
4. "I want to buy a replacement." (new order, expect it not to be handled here)
5. "What's the status of my neighbor's order?" (data boundary, expect a refusal)Message 3 is the most informative, because it checks that the topic can handle the in-scope part without sliding into the out-of-scope part. If message 4 is answered inside Order Status, the classification description needs a clearer exclusion. If message 2 is answered by promising a cancellation, tighten the scope and check that no attached action can cancel.
Exercise
A "Returns" topic has this scope: "Help customers with their purchases." Its only action is "Create Return Request." A customer asks, "Can you refund me right now?" The agent replies that the refund has been issued. Identify what is wrong with the scope, rewrite it, and name one further change you would make beyond rewording the scope.
Show answer
The scope states no specific job and no limits, so the agent has no basis to refuse a refund. It overlaps with nearly every other topic. A better scope: "Your job is to start a return request for an existing order. You cannot issue refunds or confirm that a refund will be paid." Beyond rewording, check that no attached action can issue a refund, since scope text only guides the model and does not prevent it. Also add an instruction that says what to tell the customer when they ask for a refund, and rerun a boundary test such as "Can you refund me right now?"