Sub topic 7
Reading the reasoning trace
This chapter assumes you can build or edit a simple agent in Agentforce Builder. It also assumes you know what topics, actions, and instructions are, and that you have opened a conversation record from the previous chapter. Here you learn to read the step-by-step record of how the agent reached a response, so you can say which decision went wrong.
What the reasoning trace is
A transcript shows what the customer and the agent said. The reasoning trace shows what the agent decided between those messages. For each customer turn, the trace lists the steps the agent took: which topic it chose, which actions it considered or ran, what data came back, and how it built the final reply.
The trace is the main evidence for diagnosis. A bad answer looks the same whether the cause was a wrong topic, a wrong action, or missing data. The trace tells you which one it was.
The exact labels and layout of the trace depend on your Agentforce release and on where you open it (Agentforce Builder's preview, or the session records in your org). The decision order below stays the same. Check the labels in your own org before you write them into a team guide.
The decision order within one turn
The agent works through each turn in roughly this order.
- Read the customer's latest message plus the conversation so far.
- Choose a topic by comparing the message to each topic's name, description, and scope.
- Within that topic, read the instructions and the descriptions of the available actions.
- Decide whether to run an action, and fill in its inputs.
- Receive the action output, or grounding data such as knowledge results.
- Write the reply, following the topic instructions and the data returned.
Errors flow forward. A wrong topic at step 2 makes every later step look wrong, even though those steps worked correctly on the information they had. This is why you read the trace from the top and stop at the first bad decision.
Reading a trace from the top
Use the same routine for every conversation you review.
- Find the customer turn where the answer first went wrong. Do not start at the last message, because the real cause is usually earlier.
- Open the trace for that turn.
- Check the topic. Was it the topic you would have chosen for that message?
- If the topic is right, check the actions. Was the right action chosen, and were its inputs correct?
- If the action is right, check what came back. Was the output empty, stale, or about the wrong record?
- If the data is right, compare the reply to it. Did the agent follow its instructions, or did it add something the data did not support?
The first step that fails is your diagnosis. Later steps are consequences.
A worked example
A customer writes: "I want to send back the shoes I bought last week." The agent replies: "Your order is expected to arrive on Friday." The reply is wrong, so you open the trace for that turn.
| Step | What the trace shows | Verdict |
|---|---|---|
| Topic selection | Chose Order Status | Wrong. This is a returns request. |
| Instructions read | "Handle questions about orders." | Too broad. It matches almost any order message. |
| Action selected | Order lookup, with the customer's most recent order | Correct for this topic, but not for this request. |
| Action output | Delivery date: Friday | Correct data. |
| Final response | States the delivery date | Faithful to the data and the topic. |
The failure is in the first row. The action worked and the reply followed the data. The cause is a topic description that is too broad, and no other step needs changing. If you had only read the reply, you might have edited the action or the response wording, and neither change would have helped.
The fix, from the topic spine example, narrows the scope and states exclusions:
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.What to look for at each step
Topic selection
Look for these signs.
- The chosen topic is plausible but not the best one. Two topic descriptions overlap, so the agent picked one that sounded close.
- The agent chose a general or fallback topic for a request you do cover. The target topic's description may not use the words customers use.
- The topic changed in the middle of a conversation without the customer changing subject. Follow-up messages such as "yes, that one" carry little meaning alone, so the agent may have mapped them elsewhere.
Action selection and inputs
- The agent skipped an action and answered from general knowledge. The action description may not say when to use it, or the instructions may not require it.
- The agent ran the wrong action among similar ones. Compare the names and descriptions of the candidates. If two read alike, the agent has no basis to choose.
- The action ran with a missing or guessed input, such as an invented order number. The instructions should tell the agent to ask for required values first.
- The action ran twice, or ran when nothing had changed. Look for instructions that tell it to "always check" without a stopping condition.
Action output and grounding
- The output is empty and the agent answered anyway. The instructions need a rule for the no-result case, such as the fallback in the example above.
- The output is correct but old or for the wrong record. This is a data problem, not an agent problem.
- Knowledge results were returned but are off topic, so the reply drifted. This points to grounding quality, covered in a later chapter.
The final response
- The reply contradicts the data that came back. Check whether the instructions pushed the agent toward a different wording or tone.
- The reply includes a claim that appears nowhere in the data or instructions. The agent filled a gap, so tighten the rule for what it may say when data is missing.
- The reply is correct but the agent should have escalated. Check the escalation conditions in the topic instructions.
Common mistakes when reading traces
- Starting with the final reply. The reply is the last symptom. Start at the first bad decision.
- Fixing the loudest step. A wrong topic often produces a strange action and a strange reply. Fixing the action leaves the real cause in place.
- Judging from one conversation. One trace shows one path. Before changing a shared instruction, find several similar conversations and check that they fail at the same step.
- Treating the trace as a full explanation. It records decisions and data, but you still infer why the agent preferred one option. Test your guess by changing one thing and re-running the same utterance.
- Rewriting several things at once. If you change the topic, the action description, and the instructions together, you cannot tell which change helped.
Turning a trace into a test case
Once you find the cause, write the failure as a test case before you change anything. After your fix, you re-run it, and you keep it for every later release.
Test case: Returns request is not handled by the order topic
User utterance: I want to send back the shoes I bought last week.
Expected topic: Returns
Expected action: none until the order number is confirmed
Expected response: Asks for the order number or return reason, does not give a delivery date.The case records what the trace showed was wrong (the topic), what correct behavior looks like at each step, and the exact utterance that triggered the failure. A later chapter shows how to group such cases into a regression test set.
Exercise
A customer asks, "Can I change the address on my order?" The agent selects the Order Status topic, runs the order lookup action correctly, and replies with the delivery date. The trace shows the order lookup returned accurate data. Which step do you diagnose as the failure, and what do you check before editing anything?
Show answer
The failure is topic selection, because the request is an address change and not a status question. The action and the reply were consistent with the topic they were given. Before editing, check whether a topic exists that covers address changes. If one exists, compare its description to the Order Status description to see why they overlap or why the customer's wording did not match. If none exists, the agent has no correct topic to choose, so you need to decide whether to add one or to have the agent escalate. Then write a test case for this utterance.
Exercise
A trace shows the right topic and the right action, but the action input for the order number is "12345", which the customer never typed. What is the likely cause, and what kind of change addresses it?
Show answer
The agent guessed a required input instead of asking for it. The cause is in the instructions or the action input description, which do not require the agent to collect the value from the customer first. Add an instruction such as "Ask for the order number if the customer has not given one," and make the input description state that the value must come from the customer. Then re-run the same utterance and confirm the agent asks for the number.