AI Agent Observability: Tracing, Testing, and Improving Agents
December 3, 2026
Key Takeaways
- AI agent observability records every model and tool call your agent makes, along with the context it saw, so a wrong answer or a costly run traces back to the call that caused it.
- A trace links each response to the model calls and tool results behind it, so you can pinpoint where the agent went wrong and which steps add latency and cost.
- Add production failures to a dataset to catch regressions before your users do. Evaluate a single step when that's where the problem is, and the full thread when the right answer depends on earlier turns.
An AI agent can give a convincing answer while relying on the wrong context or skipping an important step. To discover and identify this mistake, you need to see what context the agent received and which steps it took. AI agent observability lets teams inspect the context the agent received and the steps it took, helping them investigate failures that the final answer alone may not reveal.
What is AI agent observability?
AI agent observability is the practice of recording and analyzing an agent’s execution, including the context it receives and the operations it performs. It helps teams debug incorrect answers, investigate latency and cost, and when paired with evals, test whether changes improve the agent.
To put observability into practice, it’s helpful to understand some foundational terms and how they work in LangSmith, our framework-agnostic agent engineering platform.
- A run records one operation, such as a model call, tool call, or document lookup.
- A trace connects the runs within an execution, such as everything the agent does in response to a user request.
- A thread groups traces from a multi-turn conversation so you can inspect behavior across a conversation.
This structure connects an answer and the steps that produced it, helping teams investigate failures and save representative examples for future testing.
How AI agent observability helps teams debug and improve agents
Agents can choose different tools or retrieve different documents each time they attempt a task, and final answers rarely provide enough context to explain those choices, or why a run succeeded or failed.
For example, suppose a support agent tells a customer they have seven days to return an item when the current policy allows 30. Application monitoring might show that the request completed successfully, but a trace can show that the agent retrieved a retired version of the policy.
Traces support several aspects of agent development:
- Failure diagnosis: A trace can show whether retrieval returned irrelevant context, a model supplied an invalid tool argument, or an agent repeated an action in a loop.
- Cost and latency: Token counts for model calls and the duration of model and tool calls help teams identify potentially expensive or slow steps.
- Testing improvements: Representative failures and successful runs can become test examples for comparing proposed changes against production behavior.
AI agent tracing complements application logs and infrastructure monitoring by recording the inputs, outputs, and state transitions your application exposes.
When to use AI observability
Basic logs and print statements typically are enough for isolated prompt experiments with synthetic data. Structured tracing becomes more useful once agents start using tools, retrieving documents, handling multi-turn conversations, or affecting user-facing decisions.
You should also consider the risk of a mistake. Even a support agent handling a small number of refund questions may still need tracing if its answers determine whether customers receive money back.
Many organizations are already using observability to improve their agents. In our State of Agent Engineering, based on a survey of 1,340 technical professionals, 89% of respondents said their organizations had implemented some form of agent observability.
What AI agent traces capture
AI agent traces can capture model calls, tool calls, retrieval, control flow, and application state. The available detail depends on how the application is instrumented and which data it is permitted to export.
A trace connects related runs through parent-child relationships, showing how a user request led to individual tool or model calls. These relationships can extend across agent handoffs. For example, if a supervisor delegates a task to a subagent, the trace can show how the subagent’s steps relate to the original request.
Metadata adds useful context, such as the environment, prompt version, or a non-sensitive account identifier. This information can help teams identify whether failures are associated with a particular deployment or configuration.
Teams commonly capture traces through an SDK or OpenTelemetry. LangSmith supports both approaches. Its SDKs capture traces from supported integrations and custom-instrumented functions. Use OTel tracing through direct ingestion, an OTel collector, or OTel-based tracing with the LangSmith Python SDK.
Considering sensitive data with AI agent tracing
Agent traces often include the same sensitive information the agent uses to complete a task; teams need to decide what should be captured or redacted, and how long trace data should remain available.
LangSmith’s input and output masking can remove or redact sensitive data before trace payloads are sent to LangSmith. For requests routed through LangSmith LLM Gateway, data policies can redact supported sensitive data from outbound requests before they reach the model provider and control whether request and response bodies are stored in gateway traces.
Tracing also affects performance and cost. Collecting traces uses compute and network resources, storing them takes up storage capacity, and running evals uses compute and LLM tokens. Teams usually manage this by deciding which traces to sample and how long to retain them. In LangSmith, retention settings control how long traces remain available and how much they cost to store, while sampling can reduce volume at the risk of missing rare failures.
How traces capture multi-turn conversations
An agent’s response can depend on information exchanged earlier in a conversation. For example, a support agent might retrieve the correct return policy in the first turn, then overlook it when the customer later provides a purchase date. The final response alone wouldn’t show whether the agent had the right policy earlier in the interaction.
That’s why multi-turn conversations need to be reviewed as a sequence, not just as separate requests. Grouping related traces gives reviewers the conversation-level view they need to evaluate the full interaction. In LangSmith, a thread groups traces from the same conversation so teams can review behavior across multiple messages. This helps reviewers see whether an agent used earlier context, handled follow-up questions correctly, and resolved the user’s request.
LangSmith Trajectories provide a flat, ordered view of the messages in a thread, including human, AI, and tool messages, making it easier to scan the path the agent took across turns, while the underlying traces remain available for step-level debugging.
Multi-turn online evaluators assess the conversation after a configured idle period. They can evaluate an outcome that spans several messages. For agents that delegate work, the trajectory can also help reviewers follow subagent activity alongside the main conversation.
How evals measure AI agent performance
Seeing what an agent did is only the first step. To improve an agent, teams also need a way to decide whether that behavior was good, where it failed, and whether a proposed change makes the system better.
This is where evals come in. Traces show what an AI agent did during a task, and evals assess how well it performed by comparing its behavior or output against defined criteria. An eval can focus on an individual step, a complete trace, or a multi-turn conversation.
A correct answer does not establish that retrieval worked as intended, so the retrieved document and the final response can be evaluated separately. Common evaluator types include:
- Code evaluators for deterministic checks, such as whether retrieval returned the expected document version or a tool call included a required field.
- **LLM-as-a-judge evaluators** for criteria that require interpretation, such as whether an answer is supported by the supplied policy.
- Human reviewers for ambiguous, high-stakes or nuanced cases where expert judgment is needed.
Evals also differ in the data they assess.
- Offline evaluations test an agent against saved examples before release.
- Online evaluations assess selected production interactions.
LangSmith Evaluation supports both offline and online evaluation. Teams can review individual runs, send examples to annotation queues, and save representative failures to datasets for future testing. In LangSmith, automation rules can send runs with negative feedback to annotation queues for review, and reviewers can then save representative failures to datasets for future testing.
How production traces inform AI agent improvements
Observability is most useful when it leads to a concrete change in the agent. A trace can explain why something went wrong, but the next step is turning that failure into a test case and checking whether a fix holds up after deployment.
For example, our support agent might approve a return for a used item even though the store’s policy only accepts unused items. A trace could show that the agent received the item’s condition and the relevant policy, but failed to apply the policy in its response.
The team can use that production example as a test case. The same example can become part of an offline evaluation dataset, along with similar cases that cover other item conditions. After the fix is shipped, online evaluations and user feedback can show whether the issue still appears in production.
Over time, production failures become a dataset of real scenarios to test future agent versions against. Running those cases before release helps teams catch regressions they have already seen.
LangSmith Engine helps automate parts of this cycle by surfacing recurring issues in production traces, diagnosing likely root causes, and generating dataset examples from those traces. With a connected GitHub repository or GitLab project, Engine can ground its diagnosis in source code and open pull requests or merge requests for review. The team still reviews and merges any proposed changes.
Tracing and evals work together
Agent observability gives teams the context to understand failures, while evaluations provide a way to test whether changes address them. Together, they turn individual production experiences into evidence for improving an agent over time.
LangSmith brings tracing and evaluation together across frameworks and custom code. Explore the tracing quickstart to see how to capture an agent’s activity and use it as a starting point for improvement.