Tracing Agent Decisions in Production
Deepak Vishwakarma1 min read
When an agent misbehaves in production, the hardest question is not what went wrong — it's where in the chain things diverged.
The visibility gap
Token streams tell you the model's output. They don't tell you:
- Which tool was selected and why
- What arguments were passed
- How long each step took
- Whether a retry changed the outcome
Structured tracing closes that gap by recording each step as a first-class event.
What to trace
At minimum, capture these spans for every agent run:
| Span | Why it matters |
|---|---|
llm.call | Input tokens, output tokens, latency |
tool.invoke | Tool name, args, result or error |
memory.read | What context was retrieved |
memory.write | What was persisted |
Practical tips
- Attach a run ID to every trace so you can correlate user reports with logs
- Log tool errors separately from model errors — they have different fixes
- Set latency budgets per step and alert when a single tool dominates wall time
Good observability turns agent debugging from guesswork into inspection. Start tracing before you need it.