Learn › Testing & Evaluating AI Agents and RAG › Grading Agent Traces

Grading Agent Traces

Intermediate 🕐 16 min Lesson 9 of 11
What you'll learn
  • Explain what trace grading is and what it reveals
  • Build a failure taxonomy from real traces
  • Decide what a useful trace record contains
  • Distinguish reference-based from reference-free checks
  • Keep logs in a portable, privacy-aware format you control

Why Traces Matter

A final answer tells you whether a run failed. A trace tells you why. OpenAI's documentation describes a trace as the end-to-end record of model calls, tool calls, guardrails, and handoffs for one run, and describes trace grading as assigning structured scores or labels to that trace. If you need tracing basics, see Evaluation and Observability; this lesson focuses on grading what the trace shows.

Questions a Trace Can Answer

  • Did the agent pick the right tool?
  • Did it pass the right arguments?
  • Did a handoff happen when it should have?
  • Did the workflow violate an instruction or safety policy?
  • Did a change to the prompt or routing help or hurt?

Start With Traces, Then Move to Datasets

OpenAI's agent-evals guide recommends starting with traces while you are still debugging behavior: inspect a representative trace, create a grader, run it on selected traces, and use the results to refine prompts, tools, routing, or guardrails. Once you know what good looks like, move to datasets and eval runs for repeatability. Anthropic's version is blunter: read the transcripts. Numbers tell you something is wrong, and transcripts tell you what.

Build a Failure Taxonomy

Read 20 failed traces and label each with the first step that went wrong, because later errors are often consequences. Typical categories:

  • Wrong tool chosen
  • Right tool, bad arguments
  • Tool returned an error and the agent ignored it
  • Retrieval missed the needed document
  • Looped without making progress
  • Gave up too early or declared success too early
  • Violated an instruction or policy

Count the labels. If 11 of 20 failures are "ignored tool error", one fix pays off more than twenty prompt tweaks. Each frequent category then becomes a code grader or a rubric line item in your suite.

What to Record in a Trace

A useful record per run includes the input, the instructions version, each step in order, every tool call with its arguments and result, token counts and latency per step, the final output, and the final state of anything the agent changed. If you cannot reconstruct the run from the log, you cannot grade it after the fact.

Reference-Free Checks

LangSmith's concepts docs distinguish evaluators that need a reference answer from those that do not. Reference-based checks such as correctness work offline against a dataset. Reference-free checks such as format, safety, or "did the agent call a forbidden tool" can also run online on live traffic, where no ground truth exists. Many trace checks are reference-free, which makes them good monitors. LangSmith also groups related runs into threads, so you can evaluate a whole multi-turn conversation, not only single steps.

Keep Your Logs Portable

Tooling is changing quickly. OpenAI's evaluation guide announced that its Evals platform would be deprecated, with a shutdown scheduled for 30 November 2026, so check its current docs before building a workflow that depends on dashboard features. OpenTelemetry has published conventions for tracing generative AI, which have moved to a dedicated repository (open-telemetry/semantic-conventions-genai); verify the current status and attribute names there before relying on them. The safest habit is to log your own structured record per run in a format you control, so any grader or vendor can read it.

An OpenAI account is required to use its dashboard trace tools, and a LangSmith account is required for LangSmith; both are optional if you grade your own JSON logs.

Privacy and Cost

Traces often contain user data and secrets. Redact personal information and credentials before storing or sharing them, and set a retention period. Storing full prompts and tool results for every run also costs money, so you may sample routine runs while keeping every failure.

Try This

Save the traces of 10 failed runs as JSON. For each, write the step where it first went wrong and a category label. Pick the most common label and write a code check that would have caught it, then run that check over all 10 traces to see how many it catches.

Key takeaways
  • Traces show why a run failed, not just that it failed
  • Label the first step that went wrong, then count categories
  • Reference-free trace checks double as production monitors
  • Own your log format so tools can change underneath you
  • Redact personal data in traces before storing them
Learn more every week Get 5 hand-picked prompts + new AI tools every Monday. Free.