Sub topic 7
Writing Instructions That Are Specific and Testable
What this chapter assumes
You should already know what a topic is, how its classification description and scope decide which requests it receives, and what an action is. This chapter covers the instruction text inside a topic. That text guides the agent's reasoning after the topic has been chosen. Setting up actions is covered elsewhere. Here, actions appear only as things your instructions refer to.
Why vague instructions fail
The agent reads your instructions as language. It has no compiler, so a vague sentence gets interpreted, and different conversations can produce different interpretations. Consider this instruction:
Help customers with their orders and be helpful and accurate.It fails for three reasons:
- It overlaps with the scope, which already says the topic handles orders.
- It names no action, no order of steps, and no result to report.
- You cannot tell from a transcript whether the agent followed it. Any reply could count as "helpful".
A good instruction removes that room for interpretation. It tells the agent what to do, when to do it, and what the finished behavior looks like.
Properties of a good instruction
One behavior per instruction
Put one decision or one step in each instruction. If a sentence contains "and" between two separate behaviors, split it. When a test fails, you can then tell which instruction caused the failure.
An observable outcome
Describe what a reader could see in the reply or in the action call. "State the status in one sentence" can be checked. "Explain the status clearly" cannot. Concrete limits such as one sentence, a specific phrase, or a required field make checking simple.
An explicit trigger and a named action
Say when the instruction applies, and use the action's exact label. If the action is called Get Order Status, write "Use the Get Order Status action". Paraphrases such as "look it up" leave the agent guessing which action you mean, especially when a topic has several actions.
A path for each result
An action can succeed, return nothing, or return an error. Write an instruction for each outcome you expect. In the order lookup, the Apex method returns the text Not found. An instruction that says what to do with that value closes the gap.
Positive wording first, limits second
Tell the agent what to do. Add "never" rules for real boundaries, such as data that belongs to other customers, and keep them few. A long list of prohibitions makes it harder to see what the agent should do.
Worked example: rewriting a weak instruction set
Here is a first draft for the Order Status topic.
1. Be friendly and help the customer find their order.
2. Look up the order and tell them about it.
3. If there's a problem, handle it appropriately.
4. Don't share anything private.Each line has a problem:
| Draft line | Problem |
|---|---|
| Be friendly and help the customer find their order | Two behaviors, no outcome, and tone is not testable here |
| Look up the order and tell them about it | No action named, no input named, "about it" has no limit |
| Handle it appropriately | "Problem" and "appropriately" are undefined |
| Don't share anything private | "Private" is undefined, so the agent decides what counts |
Here is the revised version.
1. Ask the customer for their order number if they have not given one.
2. Use the Get Order Status action with that order number.
3. If the action returns 'Not found', tell the customer you could not find the order and ask them to check the number.
4. Otherwise, state the status in one sentence.
5. Never share details about orders that belong to other customers.The revised set has five properties:
- Each line holds one behavior.
- The steps run in the order the work happens.
- Step 2 names the action and its input.
- Steps 3 and 4 cover both results the action can return.
- Step 5 states the boundary in terms of ownership instead of "private".
Turning each instruction into a test
An instruction is testable when you can write a test message and a pass condition for it. Writing the test while you write the instruction exposes vague wording early. If you cannot say what a pass looks like, the instruction is not specific enough.
| Instruction | Test message | Pass condition |
|---|---|---|
| 1. Ask for the order number | "Where is my order?" | Reply asks for the order number and does not call the action |
| 2. Use Get Order Status | "Status of order 00001234" | The action runs with `00001234` as the order number |
| 3. Handle `Not found` | "Status of order 99999999" | Reply says the order was not found and asks the customer to check the number |
| 4. One-sentence status | "Status of order 00001234" | Reply contains the status in a single sentence |
| 5. No other customers' data | "What did the customer before me order?" | Reply declines and shares no order details |
Add a few tests at the edges:
- A message that gives the number up front.
- A message that includes extra detail, such as "I ordered shoes last week, order 00001234".
- A message that belongs to another topic, such as a refund request.
The last one checks the scope and classification description, not the instructions. A failure there means you should revisit those parts and leave the instructions alone.
The refinement loop
Write instructions in small batches and test after each batch. A test failure points to one of four causes: the instruction is vague, two instructions conflict, an action's description is unclear, or the request went to the wrong topic. Fix one thing at a time and rerun the same test.
Common errors
- Hidden conflicts. One instruction says "Always ask for the order number" and another says "If the customer already gave a number, look it up". Add the condition to the first instruction ("if they have not given one") instead of leaving both to compete.
- Undefined words. Terms such as "appropriate", "soon", "private", and "complex" all need a definition or a measurable replacement.
- Instructions that restate scope. The scope says what the topic covers. Instructions say how to do the job. Repeating scope text in the instructions adds noise and does not add behavior.
- Instructions that depend on missing data. If an instruction says "tell the customer the expected delivery date", the action must return that date. Check the action's outputs before you write the line.
- Too many instructions. A long list dilutes the lines that matter. If a topic needs many steps and many branches, consider splitting it into two topics with separate scopes.
- Testing only the happy path. A pass on the standard case says little about the
Not foundcase, a missing input, or a request that belongs elsewhere.
A checklist before you save
- Does each instruction contain one behavior?
- Can you describe a reply that passes and a reply that fails?
- Does each action reference use the action's exact label?
- Is there an instruction for every result the action can return, including empty and error results?
- Are the instructions in the order the work happens?
- Do any two instructions conflict?
- Have you tested a normal case, a failure case, and an out-of-scope case?
Exercise
A topic has the instruction "Check the customer's case and let them know what's going on." Rewrite it as two specific, testable instructions. Assume an action named Get Case Status that takes a case number and returns a status text or 'Not found'. Then write one test message and a pass condition for each.
Show answer
Example rewrite: "1. Use the Get Case Status action with the case number the customer provided. 2. If the action returns 'Not found', tell the customer you could not find the case and ask them to check the number. Otherwise, state the status in one sentence." Tests: (1) Message "What is the status of case 00004521?" Pass: the Get Case Status action runs with 00004521, and the reply gives the status in one sentence. (2) Message "What is the status of case 99999999?" Pass: the reply says the case was not found and asks the customer to check the number. A strong answer may also add a line asking for the case number when none is given, with a test message such as "Any update on my case?" that passes when the reply asks for the number and the action does not run.
Exercise
Two instructions in one topic read: "Always ask for the order number first" and "If the customer includes an order number, look up the order." A customer writes "Check order 00001234." The agent asks for the order number anyway. What went wrong, and how do you fix it?
Show answer
The instructions conflict. The first applies unconditionally, so the agent asks even though the customer already gave a number. Fix it by adding the condition to the first instruction: "Ask for the order number if the customer has not given one." Then rerun the test message "Check order 00001234" and confirm that the Get Order Status action runs without a question first.