BlogThe Instrument Problempart 2 of 2

AI Agent Evaluation: Output Decay Is Weak Evidence

Three shrinking model responses are weak evidence of agent decay; five calls plus a 60% endpoint make this behavioral check harder to fool today.

An agent trace is a time-ordered record of model calls, tool use, and outputs. One public regression test reported three model-call outputs of 784, 700, and 646 tokens in that trace. An automated check labels the run “output-length decay” with full confidence. That label sounds precise, but the three values can appear in decreasing order by chance about one time in six when their distinct values are otherwise random.

The public fix in agent-eval’s regression change raises the bar to five serial calls and requires the last output to be no more than 60% of the first. That change does not prove that a model is losing capability. It makes a behavioral check less willing to turn a common trace shape into a confident finding.

agent-eval is Tangle’s public TypeScript toolkit for running agents on representative cases, scoring results, comparing candidates, and analyzing traces. On Tangle sandboxes, defineAgentEval runs each case on its own machine, and its evaluate({ surface }) returns aggregates.byJudge for one model or prompt. The reader observes an exit code per case and a mean pass rate per surface. This post uses one of agent-eval’s public behavioral metrics to show how an evaluation instrument should set its evidence boundary.

If you are building an AI agent evaluation system, copy the reasoning rather than a project-specific implementation: use enough observations that direction alone is uncommon, require a material endpoint change, and report the result as a signal that needs interpretation.

A behavioral check is an instrument. An instrument can be useful while still producing false alarms, and once the alarm drives a release decision, the false alarm is part of the product behavior.

What an output-length check is trying to notice

A trace is a time-ordered record of one agent run: model requests, tool calls, tool results, errors, retries, and the final response. A behavioral check is a small rule that reads observable trace events and asks whether their shape resembles a known operating problem. It watches a measurable proxy and emits a signal when the proxy crosses a boundary.

The output-length check watches the model calls in one serial sequence. For each call it records an input length and an output length, then asks two questions: did the input grow, and did the output shrink in the same direction?

Growing input can be consistent with accumulating context in a long agent loop. Shrinking output can be consistent with a late-stage model that has less room to finish useful work. Together they might deserve attention. Neither pattern alone establishes that the agent degraded.

The OpenTelemetry GenAI span conventions draw the same boundary. They record token counts as span properties, which help reconstruct a run, but a recorded token count is not a diagnosis.

Why three decreasing values are weak evidence

Suppose three output lengths are distinct and can arrive in any order. There are six possible orderings.

Ordering of three distinct values Counted as decreasing?
largest, middle, smallest yes
largest, smallest, middle no
middle, largest, smallest no
middle, smallest, largest no
smallest, largest, middle no
smallest, middle, largest no

Only one of the six orderings is strictly decreasing. Under this simple random-order model the chance is 1 / 6, about 16.7%.

The model is deliberately simple. Real outputs are not independent rolls, lengths often tie or hit a bound, and serial calls share context. So 1 / 6 is not a false-positive rate for every trace. It shows how little a three-value direction test can establish. The NIST Engineering Statistics Handbook discussion of runs tests makes the same point: an ordered pattern is judged against a model of randomness and the amount of data observed.

The old check also paired output decrease with monotonic input growth. In a serial loop, later calls usually include the earlier conversation, tool results, and accumulated instructions, so input growth is a structural consequence of the loop, not independent confirmation. The linked change says so: context accumulation makes the input-growth guard largely structural evidence.

The concrete false alarm: output lengths 784, 700, and 646 decrease strictly, so the old rule fired. The endpoint keeps 646 / 784, about 82.4%, of the first output, from only three observations. The check still reported a full-confidence finding. The change turned this sequence into a regression fixture that must be rejected, so a later refactor cannot quietly reintroduce the false alarm.

Five calls change the direction question

For five distinct values there are 5!, or 120, orderings, and only one is strictly decreasing. Under the same model a five-call decrease has probability 1 / 120, about 0.83%, below the 1% threshold that makes a signal defensible.

The public implementation adds a second condition. A signal now needs both properties:

  1. At least five calls belong to the serial sequence.
  2. Every output length is no greater than the previous one, and the last is at most 60% of the first.

The second condition guards against shallow drift. Outputs of 100, 95, 90, 85, and 80 decrease, but the endpoint keeps 80% of the first output, so the rule rejects them. Outputs of 100, 90, 80, 70, and 60 meet the endpoint exactly and pass, which is evidence about this proxy, not proof that the model failed.

The public regression tests for the change encode both rejected shapes: the observed three-call 784-to-646 run and the five-call 100-to-80 run. They also keep five-call sequences that reach the boundary, so the signal stays testable rather than disabled.

The reusable pattern: name the shape that caused the false alarm, add it as a regression case, and encode the smallest extra condition that separates it from the named failure.

Why “full confidence” needs a higher bar

Confidence measures evidence strength. A confidence-1.0 finding tells a reader the observed shape is hard to get without the named problem. The old rule did not earn that: one in six distinct triples decreases even when outputs are unrelated, and the input-growth condition adds nothing in a loop that already grows its inputs.

The fix makes a narrower promise. Five calls make direction alone uncommon under the toy model, and the 60% endpoint blocks shallow trends.

The NIST Statistical Test Suite shows the right separation: a statistic is distinct from the interpretation of that statistic, and the analyst states the assumptions. An evaluator should record the same separation.

Store the sequence length, the first and last output lengths, the model and provider, the sequence boundary, and whether any usage values were missing. Without those fields a reviewer cannot tell a real five-call sequence from three calls grouped by accident with an unrelated retry.

Calibrate the check on traces where the task converges normally, traces with a forced response cap, traces with retries, and traces with missing usage. Count how often it fires in each group. That does not give a universal false-positive rate, but it shows whether the signal mostly detects a transport or prompt convention.

A runnable toy check

This TypeScript program models the rule. It is not a copy of the evaluator’s code. It checks the minimum call count, the monotonic decrease, and the endpoint, then prints the result.

Save it as output-decay.ts and run it with npx --yes tsx output-decay.ts.

import assert from 'node:assert/strict'

function isOutputDecay(lengths: number[]): boolean {
  if (lengths.length < 5) return false
  if (lengths.some((length) => !Number.isFinite(length) || length <= 0)) return false

  const decreasesEveryTime = lengths.every((length, index) => {
    return index === 0 || length <= lengths[index - 1]!
  })
  const endpointIsMaterial = lengths.at(-1)! <= lengths[0]! * 0.6

  return decreasesEveryTime && endpointIsMaterial
}

const observedFalseAlarm = [784, 700, 646]
const shallowRun = [100, 95, 90, 85, 80]
const materialRun = [100, 90, 80, 70, 60]

assert.equal(isOutputDecay(observedFalseAlarm), false)
assert.equal(isOutputDecay(shallowRun), false)
assert.equal(isOutputDecay(materialRun), true)

console.log({
  observedFalseAlarm: isOutputDecay(observedFalseAlarm),
  shallowRun: isOutputDecay(shallowRun),
  materialRun: isOutputDecay(materialRun),
})

The expected output is:

{
  observedFalseAlarm: false,
  shallowRun: false,
  materialRun: true
}

The assertions make both historical false-positive shapes fail loudly if the rule changes. The program computes no p-value and models no correlated outputs, ties, retries, or different models.

Compare models on the same cases

The toy check reads one trace. It cannot say whether a score change came from the model, the prompt, or the case mix. compare-models answers that by holding the cases, harness, and judge fixed and changing only the model. Each case gets a fresh sandbox (client.create), the agent runs the fix (box.prompt), and box.exec runs that case’s test, so the exit code is the score. evaluate({ surface }) runs the cases for one model, and aggregates.byJudge.suite.mean is its pass rate.

This version runs glm-5.3 against gpt-5.4-mini. It is typechecked against the published packages, not run on production.

import { Sandbox } from "@tangle-network/sandbox";
import { defineAgentEval, type Scenario } from "@tangle-network/agent-eval/contract";

const client = new Sandbox({
  apiKey: process.env.TANGLE_API_KEY!,
  baseUrl: "https://sandbox.tangle.tools",
});

// Same cases, same harness, same judge. Only the model changes.
const evalKit = defineAgentEval<Scenario & { task: string }, number>({
  scenarios: [
    { id: "cli-flag", kind: "fix", task: "The test tagged cli-flag fails." },
    { id: "null-guard", kind: "fix", task: "The test tagged null-guard fails." },
    { id: "timezone", kind: "fix", task: "The test tagged timezone fails." },
  ],
  baselineSurface: "glm-5.3",
  agent: async (model, scenario) => {
    const box = await client.create({
      git: { url: "https://github.com/tangle-network/sandbox-demo" },
      backend: { type: "opencode", model: { model: String(model) } },
    });
    try {
      await box.prompt(`${scenario.task} Fix the cause.`);
      return (await box.exec(`npm test -- --test-name-pattern=${scenario.id}`)).exitCode;
    } finally {
      await box.delete();
    }
  },
  judge: {
    name: "suite",
    dimensions: [{ key: "pass", description: "the tagged test passes after the turn" }],
    score: ({ artifact }) => {
      const pass = artifact === 0 ? 1 : 0;
      return { dimensions: { pass }, composite: pass, notes: "" };
    },
  },
  expectUsage: "off", // the sandbox meters each turn itself
});

for (const model of ["glm-5.3", "gpt-5.4-mini"]) {
  const result = await evalKit.evaluate({ surface: model });
  console.log(model, result.aggregates.byJudge.suite?.mean);
}

The script prints one line per model with its mean pass rate across the three cases. A gap between the two lines is a model effect on these cases, not evidence of decay in one trace. Three cases are still few, so a gap of one case is noise until more cases confirm it.

What the new signal can and cannot tell you

The rule tells you that one serial sequence has a rare-looking, materially shrinking output-length pattern under its assumptions. That is triage: it points a reviewer at the late calls, context size, tool results, stop reasons, and model configuration.

It cannot tell you why the outputs shrank. The model may have finished early, the prompts may have become more specific, the model may have hit a response limit, the trace may contain retries or a different model, or the output-token field may be measured differently by each provider. It also cannot tell you the final answer is wrong. Correct workflows can get shorter as the agent converges, and failures can produce long, confident responses. Output length is a behavioral proxy, not a quality label.

The NIST Statistical Test Suite documentation is a reminder that a pattern test needs a stated test family and data assumptions. One observed pattern is not a universal claim about a generator, and neither is this check.

The strongest use is two steps: the deterministic check marks a trace for review, then a human or a validated evaluator inspects the evidence. That separation matters most when a finding changes which agent version is promoted: at that point the signal is part of the control loop, and its false positives have a cost.

Gate a candidate prompt in CI

regression-gate puts the same comparison into CI. It scores the shipped prompt and a candidate on the same cases and exits 1 when the candidate’s mean is lower. The candidate comes from CANDIDATE_PROMPT, so a change can ship through review without changing the harness or the judge.

src/examples/evals/regression-gate.mtsRan on production 2026-11-02 from these bytes, exit 0, $0.1818 reported usage, @tangle-network/sandbox 1.0.168. View result.
import { Sandbox } from "@tangle-network/sandbox";
import { defineAgentEval, type Scenario } from "@tangle-network/agent-eval/contract";

const client = new Sandbox({
  apiKey: process.env.TANGLE_API_KEY!,
  baseUrl: "https://sandbox.tangle.tools",
});

// Run in CI: the build fails when the new prompt scores below the shipped one.
const shipped = "Fix the cause.";
const candidate =
  process.env.CANDIDATE_PROMPT ?? "Fix the cause. Change only what the test needs.";

const evalKit = defineAgentEval<Scenario & { task: string }, number>({
  scenarios: [
    { id: "cli-flag", kind: "fix", task: "The test tagged cli-flag fails." },
    { id: "null-guard", kind: "fix", task: "The test tagged null-guard fails." },
  ],
  baselineSurface: shipped,
  agent: async (prompt, scenario) => {
    const box = await client.create({
      git: { url: "https://github.com/tangle-network/sandbox-demo" },
      backend: { type: "claude-code", model: { model: "glm-5.3" } },
    });
    try {
      await box.prompt(`${scenario.task} ${String(prompt)}`);
      return (await box.exec(`npm test -- --test-name-pattern=${scenario.id}`)).exitCode;
    } finally {
      await box.delete();
    }
  },
  judge: {
    name: "suite",
    dimensions: [{ key: "pass", description: "the tagged test passes after the turn" }],
    score: ({ artifact }) => {
      const pass = artifact === 0 ? 1 : 0;
      return { dimensions: { pass }, composite: pass, notes: "" };
    },
  },
  expectUsage: "off",
});

const score = async (surface: string) =>
  (await evalKit.evaluate({ surface })).aggregates.byJudge.suite?.mean ?? 0;
const before = await score(shipped);
const after = await score(candidate);
console.log({ shipped: before, candidate: after });
if (after < before) {
  console.error("Regression: the candidate passes fewer cases.");
  process.exit(1);
}

The gate proves that the candidate passed no fewer cases in this run. With two pass-or-fail cases, the mean moves in steps of 0.5, so it cannot detect a small regression. Widen the case list before you rely on it for that.

The decision rule for builders

Use an output-length check when you have a specific failure mode in mind, the trace records the needed fields consistently, and a reviewer has a useful action after the signal fires. Do not use it as a stand-alone claim that an agent has degraded.

Before shipping a similar check, write down four things.

Question Minimum answer
What is observed? The ordered output lengths for one defined serial sequence.
Why is the shape unusual? A stated null model, with the number of observations and the assumptions exposed.
What makes the change material? An endpoint or effect-size bound tied to the failure you care about.
What happens after it fires? A review, retry, or experiment that can confirm or reject the signal.

The public change answers the first three for this narrow signal. It leaves the fourth to the product, because the detector cannot make that decision.

If your system cannot provide that follow-up, log the pattern as low-confidence telemetry and do not call it a finding.

For the earlier benchmark boundary, start with AI Coding Agent Benchmark: What CodeTraceBench Measures. Both ask adjacent questions under the same constraint: a number must measure the decision it feeds.

FAQ

Is three decreasing model outputs proof of agent degradation?

No. For three distinct values, one of six possible orderings is strictly decreasing, so direction alone is common enough to create false alarms.

Why does the check require five calls?

Five distinct values have 120 possible orderings, and only one is strictly decreasing under the simple random-order model. That makes chance direction alone less than 1%, although real traces can violate the model’s assumptions.

Why require the last output to be 60% or less of the first?

The endpoint condition rejects shallow decreases such as 100 to 80. It asks for a material change in addition to a direction that is uncommon in a longer sequence.

Does the check prove the model is worse?

No. It identifies a trace shape worth inspecting, while the cause and the effect on task quality require separate evidence.

Can I use the toy program in production?

Use it for teaching and local tests. For production, define your trace schema, missing-data behavior, retries, model boundaries, and follow-up review before treating the signal as an operational control.

Run a same-case comparison such as compare-models before you attribute a score change to a model, and gate prompt changes with regression-gate before they ship. Do not report an output-length check as a finding.