# Tracing

Log every step of a run: the prompt, each tool call with arguments and result, tokens, latency and cost. Tools like Langfuse or LangSmith show it as a clickable trace.

AI developers · Part 09: Production · Card 7 of 13 · Last updated 2026-10-13

## Analogy

Browser devtools' network tab, but for your agent's thoughts.

## In an agent

When someone says "the bot was wrong", the trace shows whether retrieval failed, the wrong tool was picked, or the model ignored the context.

## Practice

### Flashcards

- **What is tracing?** Recording every step of a run (prompts, tool calls, tokens, latency) for debugging.

### Interview questions

**Your RAG gives wrong answers. How do you debug it?**

- Check the trace: were the right chunks retrieved?
- If not, fix retrieval: chunking, hybrid search, re-ranking, metadata filters.
- If they were, fix the prompt or the model.
- Then add the failing case to the eval set so it stays fixed.

## Questions people ask

### What is tracing for AI agents?

Tracing records every step of an agent run: the prompt, each tool call with its arguments and result, tokens used, time taken and cost. Tools such as Langfuse or LangSmith show it as a clickable timeline, like the network tab in browser devtools, but for the agent's decisions.

### How does tracing help when the agent gives a wrong answer?

The trace shows exactly where it went wrong. Maybe retrieval returned the wrong chunks, the model picked the wrong tool, a tool returned an error, or the model ignored the right context. Each cause has a different fix, and without a trace you would only be guessing.

## Related concepts

- [Evals](https://studyvisually.com/learn/tech/ai-developers/production/evals)
- [Querying (every question)](https://studyvisually.com/learn/tech/ai-developers/embeddings-rag/rag-query)
- [Top K](https://studyvisually.com/learn/tech/ai-developers/embeddings-rag/top-k)
- [Re-ranking](https://studyvisually.com/learn/tech/ai-developers/embeddings-rag/re-ranking)

Web page: https://studyvisually.com/learn/tech/ai-developers/production/tracing
Study this card in the app: https://studyvisually.com/app/learn?category=ai-developers&card=tracing
