04 Trust in productionLesson 3 of 412 minIntermediateHelps to have seen:Evals
Traces and failure modes
- + conversation m01
- + reply
The diagram shows: "4821 did not arrive" ("I want my money back"), Agent (the loop: model and tools), "Refund created" (what the customer read) and Trace (each step, in order).
Highlighted: "Refund created".
Agent sends to "Refund created" carrying "refund created".
Added: conversation m01. Added: reply.
Step 1 of 9: "The agent said the refund went out"
- What a trace and a span are
- How to read traces and name failures
- The three failure categories of the MAST taxonomy
- What to record at each step, and what to mask
- How a failed trace becomes a test case
Complete traces and failures by category on the store’s 50 test conversations
Coming soon: I will measure this on the example agent and publish the number with the report.
The whole lesson as textEvery step, to read at once, search or print.
"The agent said the refund went out"
A customer complains: the agent said the R$ 189,90 refund for order 4821 was created, and the money never arrived.
What was saved is the conversation: the message and the reply. There is no way to know whether the agent called the tool, whether it failed or whether the agent only said it did.
The reply does not tell how the agent got there.
Trace and span
A is the record of a whole run, here one conversation. It is made of : one for each call to the model and one for each tool.
Each span has a start and an end, and keeps what went in, what came out and, for model calls, how many tokens it used.
One conversation, several steps, each with input and output.
The missing step is the failure
Reading the m01 trace: the model asks for buscar_pedido("4821"). The tool returns "6 days late". The model replies "refund created".
A span is missing: criar_reembolso was never called. The failure, a mystery before, shows up in one row.
Saying it did is not having done it. The trace shows the difference.
Read traces and take notes, before fixing
"The agent got it wrong" does not say what to fix. Read the failed traces and write a short note on each one, in your own words.
Then group similar notes and give each group a name. That catalog is a failure . With it, you can count what happens most and prioritize.
A named failure becomes a count. A count becomes a priority.
Three failure categories
Researchers at Berkeley annotated more than 1,600 traces from 7 multi-agent systems. The MAST taxonomy has 14 failure modes in 3 categories: system design, inter-agent misalignment and task verification.
Our reading: the three categories also work as starting labels for a single agent.
Each category calls for a different fix.
What to record at each step
For the trace to be useful, each span needs: prompt version, model, arguments and result of each tool, each guardrail’s decision, time and tokens.
With the prompt version in the trace, you can tell whether the failure started with a change. With time and tokens, the cost and latency lesson already has its data.
Record enough to replay the decision.
The trace that keeps too much data
In conversation x07, the customer asks for the refund to a Pix key that is a CPF. The trace saves the whole message, and now the CPF is in plain text in a system many people read.
Mask before saving: CPF, Pix key, address and phone become placeholders. The trace stays useful for debugging, without exposing the customer.
A trace is personal data too.
From trace to test case
A failed trace, reviewed by a person, becomes one more case in the test set: the message, the expected reply and the tools that should have been called.
It is the same format as the store’s 50 conversations. The next version of the agent is already tested against the failure a customer ran into.
Every real failure becomes a test.
Read, name, test
The trace shows each step, and the missing step is often the failure. Reading traces, you take notes, group them and count by category before touching anything.
Each reviewed failure comes back as a test case. The number to measure: how many traces of the 50 conversations are complete and masked, and the count of failures by category.
No trace, no diagnosis; no name, no priority.
Questions in this lesson
- In a conversation’s trace, what is a span?
- A call to the model or to a tool. The trace is the conversation; the spans are the steps inside it.
- The agent asks again for the order number the customer already gave. Which category?
- System design. The history did not reach the model. The problem is in how the context was built.
- The customer wrote their CPF in the conversation. What do you do in the trace?
- Mask it before saving. Traces are read by many people and kept for a long time. Personal data comes out first.
- Cemri et al., Why Do Multi-Agent LLM Systems Fail? (arXiv, v3 Oct 2025) ↗
- Hamel Husain, Why is error analysis so important? (2026) ↗
- Hamel Husain, How many examples do I need? (2026) ↗
- OpenAI Agents SDK, Tracing ↗
- OpenTelemetry, semantic conventions for generative AI ↗
- OpenAI, Harness engineering (Feb 2026) ↗
- OWASP, LLM02:2025 Sensitive Information Disclosure ↗