Best Practices for Building LLM Apps

Chapter 6 · Practice 1 of 4

Trace every model and tool call with the same request id

From Observability and data privacy

Why it matters

"The bot gave a weird answer yesterday" cannot be investigated unless you logged the call. Trace every model and tool call under one request or conversation id.

For each call, record:

  • model id and prompt version
  • input and output token counts
  • latency and cost
  • stop reason
  • tool calls and their results

For agents, keep the whole chain of steps as one trace, so you can see where a task went wrong.

With this in place you can replay the exact call, add it to your eval set and confirm the fix.