Sub topic 8
Writing topic instructions that call the action
This chapter assumes you have already added the Summarize Case prompt template to a topic as an action. It also assumes you know what a topic is: a named job the agent can do, with a scope, instructions, and actions. Here you write the text that makes the agent call that action at the right moment.
How the agent reaches the action
The agent works in two steps. First it picks a topic by comparing the user's request with each topic's classification description. Then, inside that topic, it reads the scope and instructions and decides which action to run and what to pass to it.
The prompt template never decides when to run. The topic text does. If the topic text is vague, the agent may answer from the model alone and skip the action.
The four parts of the topic text
Each part has a separate job.
| Part | Job | Common mistake |
|---|---|---|
| Classification description | Lets the agent choose this topic | Too broad, so it overlaps another topic |
| Scope | States what the topic does and does not do | Left out, so the agent drifts into other tasks |
| Instructions | Say when to use each action and how to handle its output | Written as background prose instead of steps |
| Action name and description | Help the agent match the action to the step | Generic names such as "Action 1" |
Example topic text
Topic: Case Hand-off
Classification description: Handles requests to summarize a support case for a colleague or a customer call.
Scope: Summarizing existing cases only. Does not create or update cases.
Instruction 1: When the user asks for a case summary, ask for the case number if it was not given.
Instruction 2: Once the case is identified, use the Summarize Case action and return its output to the user without rewriting the facts.Notice what each line does:
- The classification description names the user's intent in the user's own terms ("summarize a support case").
- The scope ends with a negative statement. This keeps requests like "close this case" out of the topic.
- Instruction 1 handles a missing input before the action runs. The action cannot work without a case, so the agent must collect it first.
- Instruction 2 names the action exactly as it appears in the topic, and tells the agent what to do with the result.
Writing instructions that work
- Write one instruction per decision. "Ask for the case number" and "run the action" are separate steps.
- State the trigger as a condition: "When the user asks for...", "Once the case is identified...".
- Use the action's exact label. If the action is called Summarize Case, do not write "the summary tool".
- Say what happens to the output. Without Instruction 2's ending, the agent may paraphrase the summary and change facts.
- Keep rules about the text's content inside the prompt template. Instructions say when to call it. The template's own rules, such as "at most five sentences", shape the output.
Putting formatting rules in both places creates conflicts. The agent may rewrite output that the template already constrained.
Common errors
- The agent answers without calling the action. The instructions do not clearly say when to use it, or the action description is too vague. Rewrite the trigger as an explicit condition and name the action.
- The wrong topic runs. Two classification descriptions overlap. Narrow each one to a distinct intent and add scope exclusions.
- The action runs with a wrong or empty input. No instruction tells the agent to collect the input first. Add a step that asks for it.
- The agent adds promises the template forbids. The instructions allow the agent to rewrite the output. Tell it to return the output as is.
Checking your result
After you edit the topic text, test with several phrasings of the same request, one with the case number and one without. Check that the agent asks for the missing number and then calls the action. Testing in Agent Builder is covered in a later chapter.
Exercise
A user says "Give me a summary of case 00001234", but the agent writes its own summary and never calls Summarize Case. Which part of the topic text do you check first, and what do you change?
Show answer
Check the instructions. Make sure one instruction states the trigger as a condition ("Once the case is identified, use the Summarize Case action"), uses the action's exact label, and tells the agent to return the output without rewriting. Then confirm the action's name and description clearly match the task, and retest in Agent Builder.