Feb 2026 · 12 min read
why ai agents need observability
your agent failed at step 9 of a 10-step chain. traditional monitoring shows you a 500 error. what it doesn't show you is why the reasoning drifted at step 4.
your agent just failed. it was a 10-step workflow: pull user data from postgres, enrich it with a third-party api, classify intent via gpt-4, select a tool, execute the tool, validate the output, format a response, log the result, update the database, send a webhook. it failed at step 9, the database update. a constraint violation. you stare at the error, but why the insert failed is the least interesting part. what you want to know is what happened at step 3 to produce a classification that led step 4 to pick the wrong tool, which generated an output at step 6 that looked valid but carried a malformed field that didn't surface until step 9 tried to write it.
and you have no way to find that out. your logs say "step 9: constraint violation." very helpful.
so you do what most of us building with agents do right now and re-run the entire chain, all 10 steps, with the same api calls, the same llm invocations and the same compute bill. this time you add print statements. maybe you dump the intermediate state to a json file, or squint at a datadog trace that shows you 10 spans with latency numbers and tells you nothing about why the agent chose what it chose.
that's still where most agent debugging is, and i find it a little embarrassing.
your apm tool doesn't understand agents
i want to be specific about where traditional monitoring falls down. datadog, new relic and sentry are excellent tools for request-response architectures. a user hits an endpoint, the endpoint does work, the endpoint returns. you get latency percentiles, error rates and stack traces, and you can follow a request through microservices. for that kind of system they work well.
an agent workflow behaves more like a decision tree that unfolds over time. each node depends on the output of earlier nodes, the "logic" lives in an llm's token predictions rather than in your code, and failures cascade without making any noise, because the llm doesn't throw exceptions. it hands back subtly wrong output that passes every type check you've written.
think about what you'd need to debug the scenario above. you need to see the exact prompt that went into step 3, the exact response that came back, and the specific tokens that caused the downstream classification. you need to see what context was in the window at that point, and whether pollution from an earlier step biased the model. you need to compare this run against a previous successful run and see where the decision paths diverged. you need the state snapshot at every step boundary so you can reason about what the agent "knew" at each point.
none of that is a latency metric or a stack trace, and it doesn't fit the mental model apm tools were built around.
apm tools answer "what happened and how long did it take." agent observability needs to answer "what did the agent decide, why, and what would have happened if it decided differently." those are different questions, and bolting agent tracing onto an apm dashboard feels a lot like using a speedometer to debug a chess game.
i've talked to teams running agents in production: customer support bots, data pipeline orchestrators, coding assistants with tool use. most of them describe the same situation. they have monitoring that tells them that something went wrong. they have no tooling that helps them understand why the agent behaved the way it did, or that lets them reproduce and fix the issue without re-running everything from scratch.
a handful of failure modes keep coming up. reasoning drift: the model's outputs gradually shift over a multi-step chain because context accumulates and earlier outputs bias later ones. tool selection errors: the agent picks the wrong tool at step 4, but the output looks plausible enough that nothing flags it until much later. context pollution: irrelevant information from an earlier step leaks into the prompt window and degrades performance on subsequent steps. silent degradation: the agent produces a "correct" output that's subtly different from what it produced yesterday on identical inputs, and you have no way to detect or explain the drift.
traditional monitoring catches none of these, since nothing throws and nothing is slow. the output is wrong in ways you can only diagnose if you can follow the agent's reasoning.
then there's cost. every time you re-run a 20-step agent chain to debug a failure at step 17, you're paying for 20 llm calls, 20 tool invocations, 20 rounds of compute. openai lists gpt-4 (gpt-4-0613) at $30 per million input tokens and $60 per million output tokens. if each step sends 2,000 tokens and gets 500 back, that's $0.06 + $0.03 = $0.09 a step, or $1.80 for the whole chain. debug it 15 times during development and you've burned $27 on a single bug.
now multiply that by the number of bugs you hit in a week and the number of developers on your team. it adds up fast, and every dollar of it is debugging, with no production traffic in it.
the money matters, but i care more about iteration speed. if debugging an agent issue takes 45 minutes of re-running chains and staring at logs, you get maybe 10 debug cycles in an eight-hour day. if you can fork from the exact step where things went wrong, modify the input, and replay only the remaining steps in under a minute, you get hundreds of iterations, and trying out a hunch stops costing you anything worth thinking about.
what good agent observability looks like
i think the right mental model is git, but for agent behavior. git lets you see every change, diff any two commits, branch from any point, and understand exactly how your code evolved from state a to state b. agent observability should give you the same thing for executions.
step-by-step tracing is the foundation, and by tracing i mean a lot more than "step 4 took 1.2 seconds." you want what went into step 4 (the complete prompt, the context window, the tool parameters), what came out (the raw llm response, the parsed output, the tool results), and what it cost (tokens in, tokens out, dollars, wall-clock time). that should be captured for every step automatically, without the developer having to instrument their agent code.
tracing on its own only gets you partway, though. the feature i'd want most is fork and replay.
picture clicking on step 5 in a visual timeline, seeing exactly what it received (including the tool step 4 picked for it) and what it produced, swapping in the right tool, and hitting "replay from here." steps 1 through 4 aren't re-executed because their state is already captured. the system restores the exact state at the end of step 4 and runs steps 5 through 7 with your modified input. if the result is different, you can put the original and replayed runs side by side and diff them step by step to see where the outputs diverge.
this is what we're building with timemachine sdk.
the approach is an sdk wrapper that sits around your agent's execution. you don't modify your agent logic. the wrapper intercepts each step boundary and captures the full state: inputs, outputs, llm prompts and responses, tool calls and results, timing, cost, the complete context window. it stores everything in postgresql with jsonb columns, which means you can query across executions with sql. the web dashboard renders the timeline, lets you click into any step, and has the fork & replay controls.
the captured steps go to an async, non-blocking ingestion api (diagram 02 below), so storing one step doesn't hold up the next. the state capture has to be exact: when you fork at step 5, the restored state needs to match what the original execution had at that point, byte for byte. that matters because agent behavior is sensitive to input, and a replay that starts from an approximation of the original state can't tell you much.
full state capture also makes data drift detection possible. say you run the same agent with the same inputs on monday and on friday, and the outputs don't match. the cause might be the llm producing different completions (temperature, model updates), a tool returning different data, or context pollution from a different conversation history. without step-level state capture you can't tell which one it was. with it, you can diff the two runs and see the exact step where they diverged, the exact tokens that differed, and the downstream cascade.
this matters most for teams trying to run agents reliably in production. an agent can work in the demo and in staging and still fail on a slice of production traffic in ways you can't reproduce, because you don't have the exact state that led to the failure. if you're capturing state at every step boundary, you can pull up any failed execution, inspect the full trace, fork from the relevant step, and reproduce the issue deterministically. you go from "we think we fixed it" to being able to say "we reproduced the exact failure, identified the cause, and verified the fix on the captured state."
to put rough numbers on the cost side, here's an illustrative example. say you have a 20-step agent chain and each step's llm call costs $0.09, the gpt-4 figure from earlier. a full run costs $1.80. during development, say your team re-runs the full chain 12 times per bug and hits 8 bugs a day across the team. that's 96 runs and $172.80 per day, or $3,456 over a month of 20 working days, just on debugging re-runs.
now suppose you can fork and replay from the step that matters. say the bad decision in a typical bug sits at step 13, so you restore steps 1 through 12 from capture and only re-run steps 13 through 20. that's 12 of 20 steps skipped, so each debug run costs 8 × $0.09 = $0.72 instead of $1.80, which is 60% less. in this example the monthly debugging bill drops from $3,456 to $1,382.40 (96 runs × $0.72 × 20 days), which is $2,073.60 a month saved from one change to how you debug, and it doesn't count developer time, the hours of staring at logs that become a few clicks through a visual timeline.
there are two bills here, and compute is the smaller one. the bigger one is the hours your engineers spend re-running entire chains because they can't isolate a single step.
i think what's happening right now in the agent ecosystem mirrors what happened with web services around 2010-2012. lots of teams were building microservices and distributed systems, and the monitoring story was "check the logs." it took a few years of production pain before distributed tracing became standard: google published its dapper paper in 2010, twitter open-sourced zipkin in 2012, and in 2017 uber open-sourced jaeger and datadog made its apm generally available. it got there once people accepted that request-response monitoring wasn't enough for distributed systems and you had to trace a single request across service boundaries.
agents are going through the same transition, and the gap is wider. microservices were at least deterministic most of the time: the same input produced the same output (usually). agents are stochastic. the same input can produce different outputs depending on model temperature, context ordering, and the phase of the moon. you need observability that accounts for nondeterminism, that can detect when behavior drifts, and that gives you tools to reason about probability distributions of outcomes rather than single execution paths.
my guess is that a lot of teams building agents today will learn this the hard way. they'll ship an agent that works well in development, watch it fail unpredictably in production, and spend weeks building ad-hoc logging and replay infrastructure before deciding they need purpose-built tooling. some will build it themselves and some will use timemachine or something like it, but i expect both groups to reach the same conclusion: you can't run agents in production without step-level observability and the ability to replay from arbitrary points.
i'm fairly sure agent observability ends up a standard part of the stack. what you get to decide is whether you adopt it before or after your first production incident where you spend days reproducing a bug that would have taken minutes to diagnose with proper tooling.
when an agent works in the demo and breaks in production, most people go looking for a better model or a better prompt. i think the gap between those two agents is mostly an observability problem, and very few teams are treating it as one yet.