Sub topic 8
Changing topics and instructions based on what you see
This chapter assumes you can open the conversation preview, run test utterances, and read the reasoning trace. It also assumes your agent has at least one topic and one action. Here you will turn what you saw in the trace into specific edits.
Start from the symptom
A failed test tells you where the agent went wrong. The reasoning trace tells you which step failed. Match the failure to the part of the agent that controls that step before you edit anything.
| What you saw in the trace | Likely cause | What to change |
|---|---|---|
| The wrong topic was chosen | Topic descriptions overlap or are vague | The topic's name, description, and scope |
| The right topic was chosen, but no action ran | The instructions don't say when to use the action | The topic's instructions |
| The right action ran with a wrong or empty input | The agent doesn't know where to get that input | The instructions or the action's input descriptions |
| The agent answered an out-of-scope request | The scope doesn't say what to refuse | The topic scope and instructions |
| The agent followed an unsafe request | Guardrail wording is missing or weak | The instructions, and guardrail settings in your org |
If the failure is in the topic selection step, rewriting action instructions will not help. Fix the earliest step that went wrong, because later steps depend on it.
Fixing topic selection
The agent picks a topic by comparing the user's message with each topic's name, description, and scope. Two topics that sound alike will compete. Suppose "I want to return the shoes I bought last week" landed in Order Status instead of Returns. The trace shows Order Status won because its description mentions "anything about an order."
Make each description say what the topic covers and what it does not:
Before
Topic: Order Status
Description: Handles questions about customer orders.
After
Topic: Order Status
Description: Answers questions about where an existing order is and
what its current status is. Does not handle returns, refunds, or
changes to an order.
Scope: Order number lookups and delivery status only.The "does not handle" sentence matters. It gives the agent a reason to reject the topic for a near miss.
Fixing instructions
Instructions tell the agent how to behave once it is inside a topic. Good instructions are short, specific, and written as separate rules. Write one rule per instruction so you can tell which one caused a change.
Common repairs:
- Action not used. Name the condition and the action: "When the customer gives an order number, use Look Up Order."
- Missing input. Say where the value comes from: "If the customer has not given an order number, ask for it before running Look Up Order."
- Guessing. Forbid it: "Never guess an order number. Ask the customer."
- Out-of-scope request. Say what to do: "If the customer asks about anything other than order status, say you can't help with that here."
- Unsafe request. State the boundary: "Only discuss the order of the customer you are talking to. Never share details about other customers."
Avoid vague phrases such as "be helpful" or "handle orders well." The agent can't act on them, and you can't tell whether a retest proves they worked.
Change one thing at a time
Make a single edit, then rerun the same utterance. If you change the description, the scope, and two instructions at once, you won't know which edit fixed the problem or which one broke something else. Keep a note in your test record, using the template from earlier in this tutorial:
Test: "I want to return the shoes I bought last week."
Expected topic: Returns
Result: fail (chose Order Status)
Change made: Added "Does not handle returns" to Order Status description
Retest result: (fill in after retesting)Check for side effects
An edit that fixes one utterance can break another. Narrowing Order Status may send a genuine status question to the wrong topic. After each change, rerun the failing utterance and at least two earlier passing utterances, including one that belongs to the topic you edited. The next chapter covers resetting the conversation so each retest starts clean.
Exercise
You test "Can you change the shipping address on my order?" The trace shows the agent chose the Order Status topic, ran Look Up Order, and then told the customer it could not help. You want it to explain that address changes are not supported and to point the customer to support. Which part do you edit first, and what do you write?
Show answer
The topic selection and action choice were acceptable for an agent with no address-change topic, so edit the instructions of the Order Status topic. Add one rule such as: "If the customer asks to change a shipping address, explain that you can't change addresses and tell them to contact customer support." Optionally add "changes to an order" to the topic's "does not handle" scope. Then rerun the same utterance, plus one earlier passing order-status utterance, to confirm nothing else broke.