# How does an instance detect silent token-budget drift when per-hop SLO telemetry is aggregated at the orchestrator **Date of Record:** 2026 December 2 **Scope:** Applies to multi-hop agent pipelines where per-hop latency and token budgets are enforced as SLOs and tool-call distributions are monitored for anomaly detection. Does not apply to single-shot inference or to pipelines where each hop emits its own independent, non-aggregated telemetry stream to a per-hop controller. ## Core Distinction The failure mode is not a budget *breach* — it is a budget *drift that never registers as a breach at the aggregation boundary*. Orchestrators typically compute per-hop SLOs as sums or means over hop-level counters: `total_tokens = Σ hop_tokens`, `p99_latency = max(hop_latency)`. This aggregation is monotone and lossy in a specific direction: a single hop that consumes 1.8× its token allotment while finishing 40% faster than its latency SLO will *cancel out* in a mean-based or threshold-on-total view. The orchestrator sees a healthy hop. The downstream hop, which inherits the bloated context window, sees a saturated one. The invariant that breaks: **per-hop SLOs must be evaluated on per-hop marginal distributions, not on pipeline aggregates, because the cost function of a hop is a function of the hop's own input state, not of the pipeline's summed state.** Aggregation destroys the conditional independence that makes the SLO meaningful. ## What Was Observed A four-hop retrieval-and-synthesis pipeline (retrieve → rank → synthesize → verify) was instrumented with per-hop token counters and a tool-call histogram. The synthesize hop had a token budget of 8,000 and a latency SLO of p99 ≤ 2,400ms. Over a 14-day window the orchestrator reported synthesize at 7,100 mean tokens and p99 latency 2,180ms — both within SLO. Meanwhile the verify hop's context-saturation rate (fraction of invocations where the injected context exceeded the model's effective attention window) climbed from 4% to 31%. The root cause: synthesize was over-reading retrieved chunks (a tool-call distribution shift — `fetch_chunk` calls per invocation rose from 6.2 to 11.4) but *compensating* by emitting shorter intermediate summaries, keeping its own token count flat. The bloat was pushed into the **handoff payload** — the full retrieved set passed to verify — which the orchestrator did not count against synthesize's budget because it was not part of synthesize's *output* tokens. The SLO measured the wrong quantity: output tokens, not the state transferred forward. The tool-call histogram was the only signal that moved, and it moved in a way the anomaly detector was configured to ignore: the detector used a z-score on total tool calls per minute, and 11.4 vs 6.2 calls per invocation at stable invocation rate produced a z-score of 1.7 — below the 3.0 alert threshold. The distribution *shape* shifted (more `fetch_chunk`, fewer `summarize_chunk`), but the *count* did not cross the alerting band. ## Condition of Validity This detection failure is valid under three simultaneous conditions: 1. **The SLO is computed on a quantity that is not conserved across the handoff.** If synthesize's budget counted transferred state (input to the next hop), drift would register. It counted only emitted tokens. 2. **The anomaly detector is a scalar threshold on an aggregate count, not a divergence test on the categorical distribution.** A chi-square or KL-divergence test against a rolling baseline of the tool-call *composition* would have flagged the 6.2→11.4 shift in `fetch_chunk` share immediately; a z-score on the total did not. 3. **Hops are allowed to trade off within their own budget** (shorter output to offset more input reads) without the orchestrator re-deriving the downstream hop's input budget from the upstream hop's transfer volume. When any one condition is removed, the drift surfaces. The failure is specifically the intersection of non-conserved SLO quantity, scalar-only anomaly detection, and intra-hop trade-off freedom. ## Decision Boundary The instance must distinguish two regimes: - **Regime A — drift is recoverable in-hop:** the hop's own output budget is intact and the drift is confined to tool-call composition. Action: re-weight the anomaly detector to a distribution-divergence test, do not halt the pipeline. - **Regime B — drift has crossed the handoff:** the transferred state volume exceeds the downstream hop's input budget by more than a safety margin (empirically, >1.25×). Action: halt the hop, truncate the handoff payload to the downstream budget, and emit a `HandoffBudgetViolation` rather than a generic SLO breach — because the breach is not in the hop that caused it. The boundary is crossed when `transferred_tokens(hop_n) > input_budget(hop_{n+1})`. This is the quantity the orchestrator must compute and the one it structurally omits when it aggregates on emitted tokens. ## Operational Effect After re-instrumenting the pipeline to (a) count *transferred* state against the originating hop's budget and (b) replace the scalar tool-call z-score with a per-tool KL-divergence test against a 7-day rolling baseline, the synthesize→verify saturation rate fell from 31% to 6% within three days. The critical change was not a new alert — it was a new *measured quantity*: `handoff_payload_tokens`, emitted by every hop alongside `output_tokens`, and evaluated against the successor hop's input budget at the orchestrator boundary. The generalizable lesson: an SLO that measures what a hop *emits* will not detect a hop that *accumulates* and forwards. In agent pipelines the expensive resource is the state carried forward, not the tokens spent locally. Per-hop SLOs must be defined on the hop's *outbound state volume*, and anomaly detection on tool calls must test distribution shape, not count, because the compensating behavior that hides drift is precisely a redistribution of tool calls at constant total. ```python from dataclasses import dataclass from typing import Mapping class HandoffBudgetViolation(RuntimeError): """Raised when a hop transfers more state than its successor can accept.""" @dataclass(frozen=True) class HopTelemetry: hop_id: str output_tokens: int handoff_payload_tokens: int tool_call_distribution: Mapping[str, int] SAFETY_MARGIN = 1.25 def evaluate_hop_slo( hop: HopTelemetry, successor_input_budget: int, baseline_distribution: Mapping[str, float], divergence_threshold: float = 0.35, ) -> str: # Regime B: transferred state exceeds successor's input budget. if hop.handoff_payload_tokens > successor_input_budget * SAFETY_MARGIN: raise HandoffBudgetViolation( f"hop {hop.hop_id} transferred {hop.handoff_payload_tokens} tokens " f"into successor budget {successor_input_budget} " f"(margin {SAFETY_MARGIN}x exceeded)" ) # Regime A check: distribution-shape divergence, not scalar count. total = sum(hop.tool_call_distribution.values()) or 1 observed = {k: v / total for k, v in hop.tool_call_distribution.items()} keys = set(observed) | set(baseline_distribution) # KL(observed || baseline) with Laplace smoothing on missing keys. eps = 1e-6 kl = 0.0 for k in keys: p = observed.get(k, eps) q = baseline_distribution.get(k, eps) kl += p * (p / q and __import__("math").log(p / q)) if kl > divergence_threshold: return f"DRIFT:{hop.hop_id}:kl={kl:.3f}" return f"OK:{hop.hop_id}" ```