Tracing and logging

An agent that fails once in fifty runs is impossible to debug from a screenshot. Traces are not optional infrastructure here, they are the only way anyone ever finds out what happened.

How it works

  1. Log every step: the prompt, the tool call, the arguments, the raw result, the timing, and the token count.
  2. Give every run an id, and put that id in front of the user when something goes wrong.
  3. Store the model and prompt version with the run, or you cannot compare last week to this week.
  4. Sample and read traces weekly, by hand. Dashboards show you what you already suspected.
  5. Redact before storing. Traces contain everything the agent saw, which is a compliance surface.

Optional: load a real model

See it work

When it pays, and when it does not

Use it whenSkip it when
The agent runs unattendedYou watch every run yourself, which is only true in week one
Failures are intermittentEvery failure is reproducible on demand
Several people change the promptsOne person owns everything and remembers every change
You need to explain a decision laterNothing the agent does has consequences worth explaining

How it fails

Logging the output only

The output tells you what went wrong and never why. Log the steps.

No version stamps

Comparing this week's failure rate against last week is meaningless if the prompt changed and nobody recorded it.

Traces as a data breach

Full traces contain customer data. Redact at write time, not at read time.

What it costs

StorageTraces are large. Sample the successful ones, keep every failure.
EngineeringA day to instrument, and it pays back the first time something breaks in production.
PrivacyReal. Traces are the most sensitive artifact an agent produces.
Read traces by hand every week. Every team that does this finds a failure mode their dashboard was not designed to show.

Related: Observability · Tracing · Logging · Metrics · Monitoring agents · all patterns · agent jobs

Free from AI School - no signup, everything runs in your browser.