Sub topic 8
Classifying what went wrong
This chapter assumes you can open a conversation in Agentforce and read its reasoning steps. It also assumes you know what topics, actions, instructions, and grounding are. Here you learn to sort each poor response into a failure class. The class tells you which part of the agent to change.
Why classify before you fix
A bad answer rarely says where it came from. A wrong delivery date could come from a wrong topic, a wrong action input, stale knowledge, or a missing guardrail. If you edit the first thing that looks suspicious, you may change instructions that were fine and leave the real cause in place.
A failure class is a named cause with a known place to fix it. Sorting failures into classes gives you three things:
- A consistent way to compare conversations reviewed by different people.
- A count per class, so you fix the most common cause first.
- A direct link from diagnosis to change.
The six failure classes
The classes follow the order in which the agent works. It picks a topic, follows the instructions, calls actions, reads data, and applies guardrails.
| Class | What went wrong | Typical evidence in the trace | Where you fix it |
|---|---|---|---|
| Topic | The agent chose the wrong topic, or no topic. | A different topic was selected than the request calls for. | Topic name, description, scope. |
| Instruction | The right topic ran, but the agent did the wrong thing within it. | Right topic, right action available, wrong behavior or order of steps. | Topic instructions. |
| Action | The agent chose the wrong action, skipped one, or passed wrong inputs. | Action call with a missing or wrong input, or no call when one was needed. | Action name, description, input descriptions. |
| Grounding | The answer used missing, outdated, or irrelevant knowledge. | Retrieved content does not contain the answer, or contradicts it. | Knowledge articles, retrieval setup. |
| Data | The action ran but returned wrong, empty, or error output. | Action output is empty, an error, or does not match the record. | Flow, Apex, or the underlying record. |
| Guardrail | The agent did or said something it should not, or refused something it should do. | Response includes out-of-scope content, or blocks a valid request. | Scope limits, instructions, trust and safety settings. |
Data and grounding are easy to confuse. Grounding concerns the text or records the model reads to answer. Data failures concern what an action returns. If the retrieved article is wrong, that is grounding. If the order lookup returns an empty result for an existing order, that is data.
Walk the trace in order
Use a fixed order so you do not skip a layer. At each step, ask one question and stop at the first "no".
The last branch matters. Sometimes the agent behaved as designed and the expectation was wrong. Record that as a requirements gap, not an agent defect.
A worked example
A customer writes: "I want to send back the shoes I bought last week." The agent replies with a delivery date.
Reading the trace:
- Topic selected: Order Status. The request is about a return, so the topic is wrong.
- Because the first question gives "no", you stop. The class is Topic.
The topic description said only "Handle questions about orders." That is broad enough to match a returns request. The fix narrows the scope and states exclusions, and it adds steps and a fallback.
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.Notice that the fix touches the topic description first. The instruction change supports it but would not have corrected the routing by itself.
Count failures to set priority
Once you have labeled a sample of conversations, count them. A group-by summary shows which topic and which class need attention first. The script below computes resolution rate, escalation rate, and escalations per topic from exported records.
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())With this sample the output is a 50% resolution rate, a 50% escalation rate, and two escalations for Returns. Returns is the topic to review first. Add a failure_class field to your own records and count by it in the same way.
Common mistakes when classifying
- Blaming instructions for everything. Instructions are the easiest thing to edit, so they get blamed first. Check topic selection and action output before you rewrite them.
- Judging from the final answer alone. Two failures can give the same wrong sentence. Only the trace shows which layer failed.
- Labeling several classes on one conversation. Failures can stack, but pick the earliest failing step as the primary class. Fixing it often removes the later symptoms. Note the others as secondary.
- Treating one conversation as a pattern. A single failure is an anecdote. Look for the same class and topic in several conversations before you rewrite shared instructions.
- Ignoring successful conversations. Review a few good ones too. They show what a fix must not break.
Recording a label
Keep the label format small, so reviewers actually use it. A useful record has the session ID, the primary class, an optional secondary class, the topic, a one-line cause, and the intended fix. For example: s2 | Topic | Returns routed to Order Status | description too broad | add exclusions.
Those labels become the input for the next steps. Topic and instruction failures lead to instruction tuning. Action and data failures lead to action work. Grounding failures lead to knowledge work. Escalation problems, such as a customer who could not reach a human, fall under the guardrail and instruction classes and get their own tuning step.
Exercise
An agent in the Order Status topic calls the order lookup action with an empty order number and then tells the customer the order was not found. The customer had never given an order number. Walk the decision path and name the primary failure class and a secondary class.
Show answer
The topic was correct, so continue. The action was called with an incorrect input (an empty order number), so the first "no" is at the action step. The primary class is Action (or, as an instruction cause of it, the instruction did not tell the agent to ask for the order number first). The "not found" reply is a downstream symptom: the action returned nothing because of the bad input, so a Data class label would be secondary. The fix is to add an instruction to ask for the order number when it is missing and to describe the order number input clearly in the action.
Exercise
A returns question gets a correct topic and a correct action call, but the answer quotes a return window of 14 days. The current policy is 30 days. Which class is this, and why is it not a Data failure?
Show answer
It is a Grounding failure. The agent read an outdated knowledge article, so the fix is to update or retire that article. It is not a Data failure because no action returned wrong output. The wrong content came from retrieved knowledge.