An agent trace is a structured per-step log of every LLM call, tool call, timing, token, and cost in one task run, captured by tools like Langfuse, LangSmith, or Arize Phoenix.
Imagine your agent is a detective solving a case across a whole city in one afternoon. It interviews witnesses, checks records, drives to addresses, makes phone calls. At the end of the day the case is either solved or not. If it failed, you want to know exactly where it went wrong. Was it the second interview? The wrong address on the fourth stop? Tracing is a body camera plus a notebook strapped to the detective. Every conversation, every street it walked, every call it made, every minute that passed, is recorded as a separate timestamped entry. When the case fails, you can scrub back to step seventeen and see what the detective heard, what it said, and what it decided to do next.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Define a trace as a tree of spans for one task. Spell out the per-span payload for LLM and tool calls. Explain why tree shape beats flat logs in a recursive agent. Name two or three production tracing tools and what they integrate with. Close on tracing as the load-bearing primitive that makes a non-deterministic loop debuggable.
Real products, models, and research that use this idea.
- Langfuse provides hosted and self-hosted tracing for LangChain, LlamaIndex, and the Anthropic and OpenAI SDKs, with span trees and per-step cost breakdowns.
- LangSmith is LangChain's first-party tracing product and ships built-in spans for every chain, tool, and retriever in the LangChain ecosystem.
- Arize Phoenix is an open-source tracing UI that runs locally on your laptop and is popular for development-time agent debugging.
- Helicone proxies the OpenAI and Anthropic APIs and captures each call as a span with prompt, response, tokens, latency, and cost, with no SDK changes.
- Weave from Weights and Biases provides tracing plus evaluation, used by teams that already rely on W&B for ML experiment tracking.
What an interviewer would ask next. Try answering before peeking at the approach.
QA trace captures everything that happened on a task. How do you find the trace that explains a specific user complaint a week later?
QYou add tracing and your latency goes up by 80 milliseconds per LLM call. What did you do wrong?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating tracing as a logging concern. A trace is structured: each step is a typed span with its parent, its inputs, its outputs, and its timing. Plain print statements lose the tree shape and the per-step inputs.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.