Notes

Trajectory Logging

An agent's answer is the last thing it produced, not the thing worth studying. What matters is the path it took to get there — every thought, call and observation, in order. Trajectory logging is the practice of recording that whole path as a durable sequence instead of keeping only the final output.

What gets written down

  • Each reasoning step or plan the model emitted, in sequence.
  • Every tool call with its exact arguments, and the raw observation that came back.
  • The context actually sent at each step — including what was dropped when the window was compacted.
  • Run-level facts: tokens, cost, step count, termination reason.

What it is used for
A logged trajectory is the raw material for nearly everything downstream. It is how a failure is diagnosed after the fact, since nothing reproduces reliably in a nondeterministic loop. It is the input to trajectory evaluation and LLM-as-judge scoring, which grade the process rather than just the final answer. It feeds regression suites, where yesterday's successful paths become today's tests. And it is the audit record when an agent did something consequential — the only honest answer to "why did it do that" is the sequence that led there. Frameworks differ in how much they capture by default: LangGraph persists state per node, while LangSmith and OpenTelemetry exporters capture the full trajectory as structured traces. Logging less than the input to each step is the usual regret.

Trajectory logging is the recording of an agent's full execution path — each reasoning step, each tool call with its arguments, each observation returned, and the context actually sent — rather than just the final output. Because an agent loop is nondeterministic and rarely reproduces, the logged trajectory is the only reliable basis for debugging a failure, scoring the process during evaluation, building regression suites, and auditing why the agent acted as it did.

A flight recorder does not simply note that the plane landed. It keeps everything that happened on the way. Trajectory logging is a flight recorder for software that works on its own.

When an AI assistant is given a job, it takes many steps — deciding what to do, looking things up, using tools, trying again when something fails. All of that is written down in order as it happens. If the job goes wrong, someone can read back exactly what the assistant did and where it went astray. And if it did something that mattered, that record is the honest answer to "why did it do that?" Keeping only the final answer throws all of it away.