Est.

Observability Schema Design That Makes Agent Quality Gains Accumulate Release Over Release

A span-level schema keeps agent fixes attributable and testable.

· 8 min read
Cover illustration for “Observability Schema Design That Makes Agent Quality Gains Accumulate Release Over Release”
Production Feedback · November 21, 2026 · 8 min read · 1,807 words

Production agent traces become a compounding improvement loop when teams observe behavior, diagnose failures by layer, evaluate proposed fixes, gate releases through replay, and feed new failures back into the evaluation dataset. Observability schema design makes that loop durable. The schema is the contract that keeps each improvement attributable to a specific layer, comparable across releases, and testable against historical behavior.

Why observability schemas exist and what most teams get wrong about them

A platform engineer at a Series B fintech shipped a customer-onboarding agent built with LangChain, four tools, retrieval, and an OpenAI fallback. The APM tool showed exactly two spans per request, one HTTP span into the agent endpoint and one HTTP span out to OpenAI. Forty-seven internal steps were invisible inside those spans. Within two days, three incidents followed, including a hallucinated routing number that nearly triggered a wire transfer, an excessive tool-call retry loop, and a token spike from a retrieval prompt repeated within one conversation. None was visible in the trace tool.

The trace schema defines what the debugging UI, evaluation layer, alerting system, and analytics can know about an agent. If it represents an entire workflow as an HTTP request, those consumers cannot distinguish a planning error from a retrieval failure or a retry loop. A small, opinionated schema gives them a common contract that can be enforced and evaluated, rather than a free-form log each consumer must interpret independently. Choosing that contract is an architectural decision.

The five-layer observability stack and where the schema sits in it

Twinkll Sisodia’s 2026 AI observability taxonomy divides monitoring into five layers. Layer 1 covers Model Internals, including activations and latent representations. Layer 2 covers Confidence and Calibration, while Layer 3 covers Behavioral Monitoring, including reasoning, action patterns, and safety. Layer 4 covers Operational Intelligence through metric synthesis, anomaly correlation, and SRE insights. Layer 5 covers Infrastructure Tracing across GPU kernels, inference engines, and hardware telemetry.

The schema sits primarily between behavioral monitoring and operational intelligence. One reads the spans directly, while the other synthesizes them into operational signals. Sisodia names the link between model-level confidence and infrastructure-level anomalies as a key problem still to be solved. A schema therefore needs to bridge layers 2–4 rather than leave uncertainty, behavior, and operational outcomes in separate records. The application framework, dedicated reasoning tracer, and managed tool-integration layer all need that shared structure.

Span kinds provide the common vocabulary across these components. The open-spec vocabulary includes CHAIN, LLM, RETRIEVER, TOOL, AGENT, EMBEDDING, RERANKER, GUARDRAIL, EVALUATOR, PROMPT, and DECISION. Published attribute taxonomies cover details such as model name and version, temperature, token counts, cost, latency, retrieval chunk IDs and scores, and tool arguments. These names make comparisons machine-readable. Application-specific requirements still need explicit treatment, including a system prompt hash where the chosen specification does not define one.

How the four span types map to the four failure modes agents actually exhibit

The first diagnostic surface is model and tool execution. A concrete minimum viable schema starts with a child LLM span for the planner step, followed by a TOOL span around retrieval. Nested EMBEDDING and RETRIEVER spans record retrieval.top_k, retrieval.score, and retrieval.chunk_ids. Separate LLM spans then represent answer synthesis and formatting. This structure separates execution stages that an endpoint-level trace would collapse.

Reasoning spans expose a different class of failure. They capture the model’s plan, selected action, observation, and next decision, making plan drift and wrong-branch selection visible. State transition spans record working memory before and after each step, context edits, and handoff payloads, so context loss and summarization drift have a diagnostic surface. Memory operation spans record long-term reads and writes, including queries, returned entries, relevance scores, and freshness. These expose stale reads, wrong-entity retrieval, and memory leakage between users.

MAST (2025) catalogs failures across task interpretation, planning, tool/environment interaction, and verification. AGENTSCOPE distinguishes failure localization, which identifies the root-cause step, from failure attribution, which predicts its category. Because the step where an error appears is often not the step that caused it, terminal spans alone cannot support either task reliably. Each span type is therefore both a detection surface and a repair surface, locating behavior that a targeted change can address.

Why root-cause attribution fails without layer-specific span attributes

A span name identifies a stage. Without named, typed attributes, a failed retrieval span can still leave the diagnosis at the level of an unsuccessful run. GPT-5.1’s notably low accuracy on failure-attribution datasets illustrates why raw traces plus a strong model are not sufficient. The response is structured behavioral evidence. Uncertainty scores support confidence analysis, while reasoning and action-pattern attributes support behavioral diagnosis without collapsing the two layers.

AgentDebugX (2026) formalizes debugging as Detect, Attribute, Recover, and Rerun. Detect identifies step-level errors, Attribute locates their causes, Recover proposes ranked fixes, and Rerun regenerates the trajectory around the failure point. Its DeepDebug component escalates difficult cases to a multi-round diagnosis agent that produces an auditable root-cause report. That loop needs evidence at each step. Missing state, tool arguments, or handoff details cannot be recovered merely by adding a more capable debugging interface.

The Model or Harness? paper by Raj et al. makes the intervention distinction explicit. Model-side failures identify targets for post-training, while harness-side failures point to scaffolding and tool-integration fixes. Environment or grader failures show which evaluation conditions need to be fixed. This distinction determines where engineering effort should go. A schema that records only success or failure cannot make that assignment reviewable, even when its execution timeline is complete.

The three failure categories that break schemas silently and how to design against them

Tool schema drift is the most immediate contract failure. If the tool interface and the agent’s expectations diverge, an execution trace needs enough structure to record a completed call and expose the mismatch. Tool names and arguments therefore belong in the diagnostic record. Aggregate success can conceal the underlying incompatibility. The schema’s purpose is to preserve the evidence needed to distinguish a tool-integration problem from a model error.

Prompt-eval divergence is harder to spot because each system can look consistent on its own. Someone edits a system prompt through a prompt-management UI, while the evaluation harness remains pinned to the main branch’s prompt file. Three weeks later, an unrelated regression is investigated against a prompt that does not exist in production. A first-class system prompt hash makes this divergence detectable. OpenInference defines llm.prompt_template.version and llm.prompt_template.template, but does not currently specify a hash attribute, so that requirement needs an explicit extension.

Workflow step inflation is more systemic still. A prompt change can increase average step count, cost, and latency even when success rate stays constant, so the harness should detect and block that pattern. The scaffold effect paper describes failure fingerprints that recur across models, including REASON, VERIFY/MAX_TURNS, and idle-loop/TIME patterns linked to different harnesses. These patterns indicate biases that are largely model-independent. Unless the schema distinguishes harness-originated signals from model-originated ones, teams can respond to an expanding workflow by changing the wrong component.

Making evaluation scores part of the schema so they survive across releases

The span_id is the bridge between an evaluation run and its production trace. Evaluation scores should be typed attributes on that span, preserving their context. Hallucination probability, faithfulness, answer relevance, toxicity, and JSON schema validity then sit with latency and token counts. Running the same evaluator offline on benchmark datasets and inline on production spans, or a sampled subset, makes comparisons possible across those settings.

Tail-based sampling driven by evaluation scores preserves long-tail errors that head-based sampling can miss. Because the traces kept in storage are used for replay, sampling shapes both what gets stored and how the agent improves. The canary suite adds another contract check by comparing what evaluation just scored with the main-branch composition scored yesterday. A production combination of flag state and prompt version that never passed through evaluation warrants the explicit alert “you are serving an unevaluated agent to users”.

Vincent Koc et al. (2025) argue for telemetry-aware development that brings observability and evaluation into the development loop. Their Comet Opik MCP server example lets an MCP client retrieve metrics and traces on demand so an AI-assisted IDE can use telemetry to refine prompts and code. The schema makes that retrieval coherent across versions. It preserves the relationship between a score, the behavior scored, and the composition that produced it. However, durable scores only support release decisions if replay can use them to validate proposed changes against prior behavior.

Replay validation against historical traces as the enforcement mechanism for the schema contract

Replay-first debugging starts with the tool-call log, sub-agent decisions, and intermediate state from the original run. When a run fails, replay helps find which harness component, evaluator, or handoff let the wrong state through. That differs from rerunning a task with a tweaked prompt. The original schema must contain enough evidence to reconstruct the relevant state, or the supposed replay becomes a new experiment with missing context.

The objection from another agent vendor highlights why matching execution paths is not a sufficient test of an agent’s behavior. Outcome-based scoring tied to business KPIs addresses that limitation without requiring every valid run to take the same route. The schema consequently needs typed outcome attributes alongside a sequence of actions. Judges also need false-positive and false-negative corrections accumulated into the growing harness dataset.

A small smoke tier runs quickly on every PR, while a larger core tier runs on merges and nightly. Both tiers need the same span types and attributes so that their failures produce comparable diagnoses. When a proposed change regresses, the replay harness should expose the triggering span attribute and its before-and-after values.

How to turn production agent traces into a growing eval dataset

Online evaluations keep running on a sample of live traffic and on every escalated or thumbs-down interaction. Failed sessions then become evaluation cases used to score proposed changes before they are deployed. Each release contributes new evidence to the next release’s gate. The dataset grows from behavior seen in production as well as from imagined test cases. When an unknown failure pattern emerges, it can also become the basis for a new evaluation metric.

Layer identity determines where that feedback is routed. A systematic hallucination pattern is a model-layer signal, repeated tool-call formatting failures are harness-layer signals, and a knowledge gap about a customer segment is a context-layer signal. Routing these differently avoids treating every incident as a prompt-editing problem. The scaffold effect paper reinforces the economic reason for that distinction by finding that harness choice shifts tokens-per-solved-task far more than a model upgrade. Layer-specific telemetry makes those harness improvements measurable.

The JetBrains AI Toolkit offers another implementation pattern through run-triggered traces, hierarchical inspection, “Add to Dataset”, and unit-test–like evaluations. Harness engineering becomes a first-class discipline when its changes face the same review and testing rigor as code, with the observability schema as its foundation.

Sources

  1. AI Observability for Large Language Model Systems: A Multi-Layer Analysis of Monitoring Approaches from Confidence Calibration to Infrastructure Tracing
  2. Mind the Metrics: Patterns for Telemetry-Aware In-IDE AI Application Development using the Model Context Protocol (MCP)
  3. In-IDE Toolkit for Developers of AI-Based Features
  4. AgentDebugX: An Open-Source Toolkit for Failure Observability, Attribution, and Recovery in LLM Agents

More in Production Feedback