Tracing agent runs in production

Debug tool calls without guesswork, production tracing habits for agents (LangSmith-class or similar).

code · Published 2026-11-09 · Translation: VI

Production agents fail in tool calls, retries, and hidden prompts, not only in the final text. Tracing systems (LangSmith-class and peers) record runs so you can see what the agent saw and did.

The trap is enabling tracing before redaction. Observability without privacy rules becomes a secret archive.

Decide: turn tracing on, or wait?

Policy

Policy

Enable tracing when:

  • Agents call tools or APIs in staging or production
  • Failures are intermittent and hard to reproduce locally
  • You need attribution for latency and token costs per step
  • Multiple prompt versions run behind flags and you need comparisons

Delay tracing when you cannot answer basic policy questions: what is redacted, how long data is retained, and who can access it.

Fix before you trust it: redact, sample, tag

A practical setup that stays useful:

  • Redact by default. Credentials, emails, payment fields, and raw documents.
  • Sample production. Full capture in staging. In production, sample with an override for errors.
  • Tag versions on every run. Prompt hash, model ID, and release SHA.
  • Export failures into evals. The trace is not the end. It is the input to a test case.

If you can not search and correlate traces to a support ticket without storing extra PII, you have the wrong identifiers.

Three failure modes to avoid early

Failure modes to catch early

Failure modes to catch early

  • Secret museums. API keys and customer data live in trace stores. Fix: hard redaction and access control.
  • Needle-free haystacks. You collect everything and can find nothing. Fix: sampling plus structured tags.
  • Privacy surprises. Full customer documents retained forever. Fix: retention limits and data minimization.

A weekly loop that turns traces into improvements

Once a week, pick the top recurring failure category and convert 5 to 10 traces into eval cases. Run the eval suite before and after prompt or tool changes. Observability pays rent only when it closes the loop.

Bottom line

When this fits vs when it does not

When this fits vs when it does not

Tracing turns agent debugging from guesswork into inspection, if you redact, sample, and tag versions. Treat it as production infrastructure with privacy rules. See the tool calls, then fix the system.

Related: LangChain (or not) for your first agent for the orchestration choice, and Linear issue agents for a real tool-calling workload to trace.

Share

X Facebook LinkedIn