Sub topic 11
Testing with Realistic Utterances and Refining Wording
This chapter covers how to test a topic once you have written its classification description, scope, and instructions. It assumes you know what an Agentforce agent, topic, and action are. It also assumes you can open Agentforce Builder and run a conversation in the preview panel. You should have a topic with a description, a scope, ordered instructions, and at least one action assigned to it.
A topic that reads well can still fail in a conversation. The agent is a language model, so it interprets your words instead of executing them. The only way to learn how it interprets them is to run conversations and look at what happens.
What You Are Testing
Testing a topic means checking two separate things. Keep them apart, because they fail for different reasons and you fix them in different fields.
| What you check | Question | Field you edit when it fails |
|---|---|---|
| Routing | Did the request reach this topic, and not another one? | Classification description, scope |
| Behavior | Once in the topic, did the agent do what the instructions say? | Instructions, action references |
| Boundaries | Did the agent refuse or redirect what the topic should not handle? | Scope, instructions |
If you see a wrong answer, first decide which of the three it is. An agent that gives a perfect refund policy answer from the wrong topic has a routing problem, even though the answer looks fine. Editing instructions will not help.
Build a Test Set Before You Start Editing
Do not test by typing whatever comes to mind and tweaking wording after each reply. You will not know whether a change helped or whether you got lucky. Write the test set first, as a list you can rerun.
A useful set has four groups of utterances. Using the Order Status topic from earlier chapters:
- Typical requests. Phrases a real customer uses, such as "Where is my order?" or "Has order 48213 shipped yet?"
- Paraphrases. The same intent in different words, such as "My package hasn't shown up" or "When will my stuff get here?"
- Edge cases. Requests with missing or odd information, such as a status question with no order number, an order number that does not exist, or two orders in one message.
- Out-of-scope and neighbor requests. Requests that belong elsewhere, such as "Cancel my order" or "Is this jacket waterproof?"
Real customers rarely write in the tidy phrasing the topic author uses. Include typos, short fragments, and messages that carry emotion, for example "ugh where is my order, it's been 2 weeks". If you have chat transcripts or support case subjects, copy real wording from them instead of inventing it.
Keep the set in a spreadsheet or a text file with an expected topic, expected behavior, and a pass or fail column. Here is a layout you can reuse:
ID Utterance Expected topic Expected behavior
1 Where is my order? Order Status Asks for order number
2 Has order 48213 shipped? Order Status Calls Get Order Status, gives status and date
3 my package never showed up Order Status Asks for order number
4 Order 00000 status Order Status Says order not found, asks to check number
5 Cancel order 48213 Order Status Declines cancel, offers human transfer
6 Does the blue jacket come in medium? (not this one) Does not answer from Order StatusRow 5 deserves attention. The expected topic is still Order Status, because the request mentions an order. The expected behavior is a decline. That separates a routing check from a behavior check on the same utterance.
Run the Tests in the Preview Panel
In Agentforce Builder, use the conversation preview to send each utterance. Start a fresh conversation for each test. Earlier turns stay in the context, so a long running chat can make the agent behave differently than it would for a first message. Reset or start a new session between test rows unless you are deliberately testing a multi-turn flow.
For each reply, look at more than the text:
- Which topic was selected. The preview shows the reasoning the agent used. Confirm the topic name matches your expectation.
- Which actions ran, with what inputs. Check that the action was called, that it was called at the right moment, and that the inputs are correct. An action called with a guessed order number is a failure even if the reply sounds right.
- Whether instructions were followed in order. If step 1 says to ask for the order number first, check that the agent did not look up anything before it had one.
- Tone and length. If instructions say to answer in one or two sentences, count them.
The exact layout of the preview and its trace views changes between releases. If you cannot find a detail described here, look in the current Agentforce Builder documentation for how to view the agent's reasoning and action calls.
Run each utterance more than once. A language model can give different answers to the same input. A row that passes once and fails once is not a pass. Treat it as a fragile instruction that needs stronger wording.
Diagnosing Routing Failures
A routing failure shows up as the wrong topic name in the trace, or as the agent answering generically when a topic should have matched. Common causes and fixes:
| Symptom | Likely cause | Fix |
|---|---|---|
| Request goes to a neighbor topic | The two descriptions describe overlapping intents | Rewrite both descriptions around different customer intents |
| Paraphrases miss the topic | Description is too narrow or uses internal jargon | Name the intent in everyday words customers use |
| Everything lands in one topic | Description is broad, such as "orders" | State the specific requests it matches |
| Out-of-scope request enters the topic | Scope does not state exclusions | Add what the topic does not do |
Take the overlapping pair from the plan. "Answers questions about orders" and "Helps customers with order problems" both match "my order is wrong". After rewriting to "Looks up the status and delivery date of an existing order" and "Starts a return or refund for an order the customer says arrived damaged or incorrect," the same utterance has one clear home.
When you fix routing, test the neighbor topic too. Narrowing one description can push requests into a topic that was not ready for them.
Diagnosing Behavior Failures
A behavior failure means the topic was right but the agent did something different from your instructions. Work through these checks in order.
- Is the instruction observable? "Be helpful" cannot fail, so you cannot test it. Rewrite it as a step you can see in the reply.
- Is there a conflict? Two instructions may pull in opposite directions, such as "always answer briefly" and "explain every shipping detail." Also compare with the agent-level instructions, which apply across topics.
- Is the condition clear? "Use the action when appropriate" leaves the agent to guess. Write "If the customer provides an order number, use the Get Order Status action with it."
- Is the action name exact? The reference should match the name of an action assigned to the topic. A paraphrased or misspelled name makes the match less reliable.
- Is this a job for logic? If a rule must hold every time, such as a refund limit, and it still fails after rewording, move it into a Flow or Apex action. Instructions guide a model. They do not guarantee an outcome.
Here is a typical before and after, from a test where the agent invented a status for an order that did not exist:
Before:
Look up the order and tell the customer about it.
After:
1. Use the Get Order Status action with the order number before describing any status.
2. If the action returns no order, say the order was not found and ask the customer to check the number.
3. Never state a status or delivery date that did not come from the action result.The "after" version fixes three things at once: it orders the steps, covers the failure path, and states a prohibition tied to a visible source. That is also what makes it checkable. You can test row 4 and see whether step 2 happened.
Change One Thing at a Time
When a test fails, resist rewriting the whole topic. Change one field, or one instruction, then rerun the entire test set. This matters for two reasons.
First, if you change three things and the test passes, you do not know which change worked. You also will not know which one to keep when a later test breaks.
Second, an edit that fixes one row can break another. Adding "Always ask for the order number first" fixes row 1, but it can break row 2 if the agent now asks for a number the customer already gave. Rerunning the full set is the only way to catch this regression, which is a previously passing behavior that now fails.
Keep a short change log next to the test set: the date, the row that failed, the edit, and the result. After a few rounds it shows which wording problems recur, and it helps a teammate understand why an instruction reads the way it does.
Writing Instructions That Survive Rewording
Some patterns repeatedly make instructions pass tests. They are worth using as defaults when you revise.
- Pair a condition with one behavior. "If the customer asks to return an item, say you can't process returns in this topic and offer a human transfer."
- Name the source of truth. "Use only the action result" prevents invented details.
- State the fallback. Every lookup can fail, and the agent needs to know what to do when it does.
- Prefer positive actions plus one clear prohibition. A long list of "never" rules is hard for the agent to weigh and hard for you to test.
- Keep each instruction short. One condition and one outcome per line makes it clear which line failed.
Avoid adding emphasis such as capital letters or repeated warnings as your first response to a failure. Emphasis may help once, but it hides the real problem, which is usually a vague or conflicting instruction. Try restructuring first.
Know When to Stop Editing Wording
Testing also tells you when wording is the wrong tool. Signs that you have hit that limit:
- The same row fails intermittently after several reasonable rewrites.
- The rule involves exact numbers, thresholds, or required sequences, such as "refund only if under 30 days and under $100."
- The cost of one failure is high, such as an incorrect refund or exposed personal data.
In these cases, move the decision into a Flow or Apex action that returns a clear result, and let the instruction tell the agent how to present that result. Then test again. The test set you built will show whether the change worked.
A Short Worked Round
Suppose row 3, "my package never showed up," goes to a general fallback and not to Order Status. The trace shows no topic matched.
- Diagnose: this is routing, because the topic never ran.
- The classification description reads "Handles inquiries about order shipment status." The words "package" and "never showed up" are not close to it.
- Edit only the description: "Handles customer questions about where an existing order is, when it will arrive, or whether it has shipped, including packages that are late or have not arrived."
- Rerun all six rows. Rows 1 to 4 still pass. Row 3 now routes correctly. Row 6 still stays out.
- Log the change and move on.
One edit, one cause, a full rerun. That is the whole method.
Exercise
A customer writes "Cancel order 48213." Your Order Status topic is selected, and the agent replies by canceling nothing but also gives no guidance. The scope says the topic does not cancel orders. Is this a routing or behavior failure, which field do you edit first, and what would a testable instruction look like?
Show answer
It is a behavior failure, because the correct topic was selected. Edit the topic instructions first. Add a condition and one outcome, for example: "If the customer asks to cancel or change an order, say you can't cancel orders in this topic and offer to transfer them to a human agent." Test with the same utterance and a paraphrase such as "I don't want order 48213 anymore," and rerun the rest of the set to check for regressions.
Exercise
You change an instruction so the agent always asks for the order number first. Row 1 now passes, but row 2 ("Has order 48213 shipped?") fails because the agent asks for a number it already has. Why did this happen, and how would you fix the wording?
Show answer
The new instruction was unconditional, so it fired even when the customer supplied a number. This is a regression, caught only by rerunning the whole test set. Make it conditional: "If the customer has not provided an order number, ask for it. If they have, use the Get Order Status action with that number." Then rerun every row.