Sub topic 5
Instructions and Scope Inside a Topic
This chapter assumes you know what a topic is and how a request is matched to one. It also assumes you have a basic familiarity with Flow or Apex. Here you will see how the scope and instructions inside a topic control what the agent does once the topic is chosen.
Two different jobs
A topic has a classification description and a scope. The classification description helps the agent decide whether a request belongs to the topic. The scope states what the agent may and may not do after it enters the topic. Instructions then say how to behave step by step.
| Part | Question it answers | Used when |
|---|---|---|
| Classification description | Does this request fit here? | Choosing the topic |
| Scope | What is in and out of bounds? | Reasoning inside the topic |
| Instructions | What should I do, in what order? | Choosing actions and writing the reply |
Writing scope
Scope is a short statement of responsibility. A good scope names what the agent does and what it does not do. The exclusions matter because they stop the agent from stretching a topic to cover nearby requests.
The Order Support topic from the spine shows this:
Scope: Look up order status and explain it. Does not process returns, refunds, or changes to an order.If a customer asks for a refund, this scope tells the agent that the request is outside the topic. Without the second sentence, the agent might try to improvise an answer.
Writing instructions
Instructions are a list of rules the agent reads each time it reasons inside the topic. They work best when each one is a single, checkable statement. Here is the full topic:
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 instruction does a specific job:
- The first handles a missing input. The agent asks instead of inventing a value.
- The second ties the answer to an action. The agent looks up data first, so the reply is grounded.
- The third covers the failure case. The Apex example returns
Not Found, and this instruction tells the agent what to do with that value.
Notice that the instructions refer to the action by its purpose, "the order status action". The action's label is Get Order Status. Keeping the wording close to the action's label and description makes it easier for the agent to connect the two.
Common errors
- Vague scope. "Help with orders" overlaps with returns, billing, and shipping topics. Requests then land in the wrong topic or the agent attempts work it has no action for.
- Missing exclusions. If the scope never says what is out of bounds, the agent may try to answer anyway.
- Instructions that contradict each other. "Always answer briefly" and "Always explain every status in detail" give the model no clear choice.
- Instructions that need an action the topic lacks. If an instruction says to check a refund policy but no action does that, the agent cannot comply. It may guess.
- Overlap between topics. Two topics with similar scopes make classification unreliable. Fix the scope of each, not only the instructions.
How instructions affect action choice
Instructions do not run the action. The agent still decides, at each step, whether to call an action. Instructions shape that decision by saying when an action should be used and what must be true first. In the example, the order number must be collected before the lookup. The action's own input descriptions then tell the agent what value to pass.
Exercise
A customer in the Order Support topic asks to cancel an order. The scope says only "Look up order status." Name one change that would make the agent behave more reliably, and explain why.
Show answer
Add an exclusion to the scope, such as "Does not process returns, refunds, or changes to an order," and optionally an instruction on what to say for such requests. The exclusion tells the agent that cancellation is out of bounds, so it does not attempt an answer it has no action to support.