Production Learning Review

Output Contract Instrumentation as the Missing Layer Between Tool Return Values and Quality Degradation

Checking tool outputs at the boundary exposes silent failures that final-answer evals miss.

· 9 min read
Cover illustration for “Output Contract Instrumentation as the Missing Layer Between Tool Return Values and Quality Degradation”
Production Signal Theory · November 22, 2026 · 9 min read · 1,934 words

To detect silent tool failures in production multi-agent pipelines, output contract instrumentation must sit between tool execution and model reasoning. That layer checks schema shape, temporal validity, and byte-level integrity, and records the arguments and responses needed to trace failures to their source. A successful return message is not proof that a tool fulfilled its contract, and replacing the model is not a reliable repair for a broken tool boundary.

Why tool return values carry implicit contracts that agents cannot enforce on their own

ContractBench (Wang et al., 2026) uses presigned URLs as an example of an observation contract. A tool can return a valid URL that becomes unusable before the agent passes it to the next operation. The agent can also pass it forward before expiry but alter bytes that must remain unchanged. These are separate failures with different causes. Refreshing an expired artifact restores temporal validity but does nothing to protect it from corruption in transit.

The same distinction applies to session tokens and OAuth state parameters, whose use is constrained by the external system that produced them. Tool outputs are therefore constrained artifacts. Their acceptability depends on how and when another component uses them, rather than only on whether the response looks correct when received. AWS specifies that a presigned S3 URL must be used before expiration and that request parameters must match between generation and use. A readable URL alone proves neither condition.

The model component has no built-in mechanism that enforces these constraints. It reasons over observations and produces subsequent actions. That behavior works for ordinary content, but integrity-sensitive artifacts must be kept exactly as they are instead of being interpreted, and time-limited artifacts need explicit validity checks. The gap is between getting an output and checking that it is still safe to use. General tool-use ability does not close that gap.

How existing evaluation approaches miss contract failures entirely

LLM-as-judge evaluation assesses semantic quality, while static output gates assess the format of the terminal response. Neither approach, when applied only at that endpoint, observes the intermediate tool boundary. A malformed argument at step 2 can corrupt every step that depends on it without causing a hard failure. The final answer may still make sense and have the right format. The flaw then looks like poor model reasoning rather than a contract violation from an earlier step.

Offline evaluations have another limit because frozen fixtures do not change as tools do. A fixture can continue returning the expected field after a live vendor has renamed it. The evaluation stays green while production answers degrade. Even evaluating a reported action is insufficient if the evaluator never establishes that the action changed the underlying state. This separates evidence of a successful message from evidence of successful execution.

Bellibatlu et al.’s executable-contract audit examined four agent benchmarks and exposed that distinction inside the evaluation environment itself. MedAgentBench provided the sharpest illustration. Every write call told the agent “POST request accepted and executed successfully” while no record changed, and the grader treated the message as evidence.

Three failure categories that contract instrumentation makes visible

Diagram: Three Contract Failure Classes at a Glance. Visualizes: Show a ranked or stepped breakdown of the three output contract failure categories identified in the article: (1) Schema mismatch — wrong field types, missing required keys, invalid…

Schema mismatch is the most dangerous class because the tool returns data that violates the shape promised to its consumer. Waxell identifies wrong field types, missing required keys, invalid JSON, and truncated payloads within this category. Consider a vendor renaming items to results. The agent can interpret the missing items field as an empty result and report “no matching records found” even though records exist. No exception is needed for that failure. Memory-Induced Tool-Drift in LLM Agents identifies tool schema drift as a category in which outputs can become corrupted without an exception.

Partial data is different because the response conforms to its schema but does not contain everything required. Pagination may stop before all the results arrive, a timeout may return only the records available at that point, or a rate limit may cap the response. Repeating the identical call does not address that condition. A narrower filter or smaller page might. Recovery therefore depends on recognizing incompleteness rather than treating every deficient response as a transient transport error.

Semantic garbage passes both shape and completeness checks. An agent may supply a customer name where an ID is expected, or use a filter value that is semantically close but syntactically wrong. The response can look entirely normal. Its content is nevertheless wrong relative to the requested task, so schema validation alone cannot detect it. Distinguishing this class from the other two requires the argument, schema context, and response in execution order.

ContractBench adds temporal validity and byte-level integrity as orthogonal axes alongside those categories. It reports that no existing benchmark evaluated both axes before its introduction and that none of the 38 tested models cleared a high compliance threshold. Model scaling was not a dependable remedy. Agentic post-training could erode compliance through sycophancy-driven regression, directly challenging the assumption that a newer or larger model will preserve tool contracts better.

How do you debug a pipeline that returns wrong answers but no errors?

In a compound agentic system, the component that exposes a bad answer may be far downstream from the component that caused it. An upstream contract violation feeds into another agent’s input and then into its reasoning context. By the time quality visibly declines, the originating boundary is obscured. Without an observation at that boundary to compare against a known contract, diagnosis becomes a search through reasoning, memory, tool execution, and agent communication.

OpenRCA classifies observed failures into 12 pitfall types spanning intra-agent reasoning, inter-agent communication, and agent-environment interaction. That breadth explains why a terminal symptom rarely identifies its cause. Schema drift can look like a model going off-task, while stale memory can look like a limit on what the model can do. Prompt ambiguity can look like faulty reasoning.

The 2026 “Model or Harness?” taxonomy organizes 41 failure modes around a useful distinction. Model-side failures are targets for model improvement, while harness-side failures are targets for harness iteration. Boundary instrumentation makes that distinction actionable by locating the contract that failed before downstream behavior obscures it. Attribution becomes expensive when the evidence needed to separate layers was never captured, allowing a renamed vendor field to trigger a model upgrade or a broad harness rewrite.

What output contract instrumentation looks like as a harness layer

Output contract verification belongs between tool execution and model reasoning, with typed validators at every tool boundary. The layer captures the argument, schema context, and response in sequence before the response enters the next reasoning step. It makes the dependency explicit. Agentic Harness Engineering (Lin et al., 2026) places tools, middleware, and long-term memory within the controllable ensemble around the model, evolving those components through an observability-driven loop. Contract checks fit within that ensemble as boundary controls.

Consumer-driven contracts name the fields that the agent needs. If a tool returns twenty fields but the agent reads four, that four-field subset is the critical consumer contract. Additions elsewhere need not break it. Renaming a required field, however, should produce a red build before it degrades an answer. Pact, schemathesis, and oasdiff provide the microservices contract-testing analogy for making those dependencies explicit.

Schema-based checks complement that consumer view by comparing a versioned specification with live behavior, recording traffic, and asserting conformance. Oasdiff-style tooling distinguishes breaking errors, potentially breaking warnings, and non-breaking informational changes. A high-risk difference can fail the build. This catches interface changes, but temporal validity and byte integrity require different validators because neither is established by a structurally correct response.

ContractBench provides a concrete implementation reference for those checks. A virtual clock controls time for validity tests, while SHA-256 hashes verify byte integrity. Both are deterministic and programmatic, with no LLM-as-judge in the loop. Deliberate near-miss tests extend coverage by dropping a field, injecting null into a non-nullable field, swapping an integer for a string, or returning an unexpected empty array. Returning more rows than the context window can hold tests another boundary condition that a tidy fixture may conceal.

Real-time tracing then connects validation results to execution. Schema validation policies can catch malformed arguments in-run before they propagate, while ordered traces support comparison across context window lengths. The diagnosis can then focus on a specific tool call. That is more useful than knowing only which runs degraded, because it connects a quality change to the argument, response, and contract in effect at the responsible boundary.

Replay-based validation as the feedback loop that keeps contracts honest over time

Instrumentation closes the repair loop only when the conditions behind a violation can be exercised again before a fix ships. Testing a repair on new inputs does not establish that it resolves the original failure. Recorded tool outputs and sandboxed side effects provide a repeatable basis for replay. A harness can set golden tasks, replay calls deterministically, score results with real rubrics, and block regressions in CI while keeping the link to production traces.

That connection is essential because contract failures depend on runtime conditions and context states that static fixtures do not reproduce. Waxell identifies live tool behavior as a central source of the gap between offline and online coverage. Production evidence therefore supplies more than additional test examples. It identifies which tool definitions, routing rules, and verification steps need investigation when an agent selects the wrong tool, supplies invalid arguments, or enters a loop.

ReHarness reports consistent gains over strong raw-context baselines, memory- and reflection-based methods, and prompt optimization approaches across three continual learning benchmarks and three language model backbones. ReHarness uses harness changes as repair artifacts. Cursor shows the broader continuous-feedback principle by often retraining its Tab model through an automated process based on which suggestions were accepted or rejected.

Replay nevertheless has a defined scope. Harness evolution algorithms do not reliably enable agents to solve previously unsolved tasks and can overfit training tasks, especially with weaker models. That limitation is a serious objection to claims of generalization. Replay establishes whether a repair addresses recorded failure conditions without breaking established behavior. New failures need different techniques, and using replay as proof that a system can handle them would give it a contract it cannot fulfill.

Why harness iteration outperforms model replacement as the response to contract failures

Diagram: Harness vs. Model: Where the Performance Spread Lies. Visualizes: Show a magnitude comparison between two spreads in a software-engineering benchmark setting: the spread between harness marginal means is more than twice the spread between…

When Agents Fail” (2026) quantifies the influence of harness choice in a software-engineering benchmark setting. The spread between harness marginal means is more than twice the spread between model marginal means for Mean-of-4 and more than three times that spread when taking the best result from 4 runs. Within that setting, harness choice has the larger effect. ContractBench reaches a compatible conclusion from compliance testing, where scores range from 0% for weaker models to the mid-seventies for the strongest. Neither finding supports treating a model upgrade as a dependable contract repair.

The appropriate repair follows the attributed defect. Schema drift points to the tool description and schema validation policy, prompt ambiguity points to the prompt, and workflow loops point to memory management and loop-detection logic. The “Model or Harness?” taxonomy separates these repair targets from model-side weaknesses.

A smaller model with a well-instrumented harness can outperform a larger model operating against an unvalidated one. Programmatic checks, noise-calibrated decision rules, and outcome-reward RL on solved tasks provide distinct contributions. Targeted repairs remain narrower than generalization claims. Correcting field-rename drift in a specific tool addresses a named defect with a testable boundary.

The engineering posture follows from that specificity. A detected violation can be attributed to a layer, replayed against historical traces, and repaired where it originated. The release decision then rests on evidence tied to the observed production failure. The fix is verifiable before it ships.

Sources

  1. ContractBench: Can LLM Agents Preserve Observation Contracts?
  2. Do Agent Benchmarks Do What They Say? An Executable-Contract Audit of Tool-Using Agent Environments

More in Production Signal Theory