Sub topic 9
Improving topics and instructions
This chapter assumes you can edit topics, instructions, and actions in Agentforce Builder. It also assumes you can read a conversation's reasoning trace and have already labeled a failure as a topic or instruction problem. Here you will rewrite the text that caused it.
Why topic text is the first fix to try
The agent picks a topic by comparing the customer's message with each topic's name and description. It then follows that topic's instructions. If the wrong topic is chosen, the description is usually too broad, too vague, or overlaps with another topic. If the right topic is chosen but the steps go wrong, the instructions are the problem.
Fix one cause at a time. Changing several things at once makes it impossible to tell which edit helped.
Find the pattern before editing
Start from data, not from one bad conversation. Group reviewed sessions by topic and count escalations. The topic with the most escalations is the first to review.
from collections import Counter
# Hypothetical export of reviewed sessions. Field names are illustrative,
# not an Agentforce schema.
sessions = [
{"id": "s1", "topic": "Order Status", "resolved": True, "escalated": False},
{"id": "s2", "topic": "Returns", "resolved": False, "escalated": True},
{"id": "s3", "topic": "Returns", "resolved": False, "escalated": True},
{"id": "s4", "topic": "Order Status", "resolved": True, "escalated": False},
]
total = len(sessions)
resolution_rate = sum(s["resolved"] for s in sessions) / total
escalation_rate = sum(s["escalated"] for s in sessions) / total
escalations_by_topic = Counter(s["topic"] for s in sessions if s["escalated"])
print(f"Resolution rate: {resolution_rate:.0%}")
print(f"Escalation rate: {escalation_rate:.0%}")
print("Escalations by topic:", escalations_by_topic.most_common())In this sample, Returns accounts for every escalation, so it is the topic to open first.
Rewrite the description
A good description says what the topic covers and what it excludes. The boundary matters most when two topics sit close together.
BEFORE (topic description)
Handle questions about orders.
AFTER (topic description)
Handle questions about the status, tracking, and delivery date of an existing order. Do not handle returns, refunds, or cancellations.
AFTER (instruction)
Ask for the order number if the customer has not given one. Use the order lookup action to get the status. If no order is found, say so and offer to connect the customer to a human agent.The word "orders" also fits a return, so the old description pulled returns requests into the wrong topic. The new one names the scope and the exclusions. The instruction adds an explicit order of steps and a fallback.
Rules for good instructions
- Write one action per instruction, in the order it should happen.
- Name the action to call, using the same wording as its description.
- State the condition: "if the customer has not given one," not "when needed."
- Add a fallback for when the action returns nothing.
- Say what not to do only when you saw the agent do it.
Avoid long lists of rules. Each added rule is another thing the agent can weigh wrongly, so remove rules that no failure has justified.
Common errors
- Making a description broader to "catch more," which increases overlap.
- Fixing one conversation without checking how the edit affects other topics.
- Writing instructions that contradict the action's own description.
- Skipping the regression test, so an old failure quietly returns.
Exercise
Customers who write "I want to send back my shoes" are routed to a topic described as "Handle questions about orders." Which part do you edit first, and what do you add to it?
Show answer
Edit the description of the order topic. Narrow it to status, tracking, and delivery date of an existing order, and state that it does not handle returns, refunds, or cancellations. Then add a test case with this utterance and the expected topic Returns.