# Which invariants prevent SLA drift when a contract-negotiating agent decomposes a task across a noisy capability channel **Date of Record:** 2026 November 29 **Scope:** Applies to A2A/MCP-style handoffs where a delegating agent (the *principal*) negotiates a capability contract with a sub-agent (the *contractor*) and then decomposes a task into SLA-bound subtasks whose guarantees are asserted from the negotiated contract rather than from the contractor's per-step telemetry. Does not apply to single-agent tool calls where the caller observes each tool result synchronously and can re-plan inline. ## Core Distinction The failure is not "the sub-agent was wrong." The failure is that the principal *believed the contract instead of the execution*, because the contract was negotiated over a lossy capability channel and the decomposition step treated the negotiated SLA as a postcondition that holds by construction. Two distinct objects exist after negotiation: 1. **The advertised contract** — what the contractor declared it can do (`max_latency_ms`, `schema_version`, `determinism: "seeded"`, `retry_semantics: "idempotent"`). 2. **The realized contract** — what the contractor actually does under the specific input distribution, load, and schema the principal is about to send. The invariant that prevents drift is: **every subtask's guarantee must be re-derived from realized telemetry of that contractor on that subtask class, and the advertised contract may only be used to *bound the search*, never to *assert the postcondition*.** A principal that decomposes using the advertised contract as postconditions has silently promoted a claim into a fact. The gap between the two objects is the entire failure surface, and it is non-obvious because the negotiation step *looks* like verification — it has a round-trip, a schema, an ack, and often a signature. ## What Was Observed A principal agent P negotiated with contractor C for a 12-subtask document-analysis job. C advertised `determinism: "seeded"`, `p95_latency_ms: 400`, and `schema_version: "v3"`. P decomposed the job into 12 subtasks, assigned each a 400ms SLA and an idempotent-retry policy, and dispatched them concurrently. Three failure traces were observed: - **Determinism claim was conditional, not global.** C's "seeded" determinism held only for `schema_version: v3` *with* `temperature` omitted. P, following its own default config, sent `temperature: 0.0` explicitly. C's adapter treated any explicit temperature as a cache-bypass and a reseed, so two retries of the same subtask produced different outputs. P's idempotent-retry assumption converted a transient timeout into a *divergent duplicate*: subtask 7 was written twice with different content, and the merge step silently kept the last writer. - **The p95 SLA was a population statistic, not a per-call bound.** P enforced a per-call 400ms timeout. Under the concurrent fan-out of 12, C's queueing pushed tail latency to 1.9s; 8 of 12 subtasks timed out and were retried, tripling C's load and pushing tail latency further. The SLA was *violated by the act of enforcing it* — a classic retry-storm amplification where the guardrail is the load source. - **Schema negotiation succeeded at the envelope level and failed at the payload level.** The `v3` ack validated the top-level envelope. C's `v3` parser rejected a nested optional field (`sections[].confidence`) that P's own schema allowed but C's documented `v3` did not. The ack was truthful about what it checked and silent about what it did not. All three traces share one structure: the negotiated contract was *true as stated* and *false as used*. No party lied. The decomposition was the lossy step. ## Condition of Validity The advertised-contract-as-postcondition shortcut is only sound under a conjunction that is almost never satisfied in practice: 1. The contractor's capability declaration is **total** over the input distribution P will actually send (not just the envelope schema). 2. The declared SLA is a **per-invocation bound**, not a population percentile measured under a different concurrency regime. 3. The declared determinism/idempotency is **unconditional** with respect to any parameter P might set, including defaults P does not know it is setting. If any conjunct fails, the contract is a *prior*, and the principal must run a calibration probe — a small, cheap invocation of the exact subtask class with the exact parameter set — before it is entitled to assert the SLA on the remaining subtasks. The probe is the mechanism that converts the advertised contract into a realized one. Without it, the principal is decomposing against a hypothesis. The boundary is sharper than "test your integrations." The principal cannot in general know which conjunct failed, because the failure is *inside the contractor's adapter*, behind a channel that only reports envelope-level truth. The probe is not optional diligence; it is the only observation channel that reaches the payload layer. ## Decision Boundary The principal must choose, per subtask class, between two decomposition modes: - **Asserted mode** — dispatch all subtasks concurrently against the advertised SLA. Permitted only when the calibration probe on that exact class returned within SLA *and* the probe's parameter set is byte-identical to the dispatch parameter set *and* the probe was run at the dispatch concurrency. If any of these is unknown, asserted mode is unsound. - **Calibrated mode** — run one probe, measure realized latency and output stability (dispatch the probe twice, diff the outputs), then set per-subtask SLA to `max(advertised, realized_p95 * safety_factor)` and set concurrency to `floor(contractor_declared_capacity / realized_p95)` rather than to the fan-out the principal wants. Retry policy is downgraded from idempotent-assumed to idempotent-verified only if the double-dispatch diff was empty. The boundary condition that trips most implementations: **the probe itself must be dispatched through the same channel and parameter path as production, or it calibrates the wrong object.** A probe sent via a direct SDK call while production goes through the A2A gateway measures a different queue, a different adapter, and often a different schema-version resolution. The probe must be indistinguishable from a production subtask except in payload. ## Operational Effect When the invariant is enforced, the observable effects are: - **Retry storms stop being self-inflicted.** Concurrency is derived from realized capacity, so the guardrail no longer generates the load that violates the guardrail. Tail latency stays inside the calibrated bound because the bound was measured at the dispatched concurrency. - **Divergent duplicates become detectable rather than silent.** Because idempotency is verified by double-dispatch diff before it is relied on, a non-idempotent contractor surfaces as a probe failure at decomposition time, not as a last-writer-wins merge corruption at commit time. - **Schema mismatch is caught at the payload layer.** The probe exercises a real nested payload, so envelope-level acks can no longer mask payload-level rejections. The principal learns which optional fields the contractor's parser actually accepts, which is information the negotiation channel structurally cannot carry. - **The cost is one probe per subtask class per contractor per parameter-set**, which is bounded and amortized, and which is the minimum observation required to make the advertised contract falsifiable. The residual risk after enforcement is *distribution shift*: the probe calibrated class X, and a later subtask in class X arrives with an out-of-distribution payload that the contractor handles slower or non-deterministically. This is why the calibrated SLA carries a safety factor and why the principal must re-probe on any payload whose structural hash falls outside the probe's observed cluster. The invariant bounds drift; it does not eliminate it, and a principal that treats calibration as a one-time gate has merely moved the same failure one layer down. ```python import hashlib import time from dataclasses import dataclass, field class SLAContractViolation(RuntimeError): """Raised when a subtask is dispatched under an SLA that was never realized.""" @dataclass class AdvertisedContract: contractor_id: str schema_version: str p95_latency_ms: int determinism: str # e.g. "seeded" -- conditional, treat as prior retry_semantics: str # e.g. "idempotent" -- unverified claim @dataclass class RealizedContract: contractor_id: str subtask_class: str param_fingerprint: str realized_p95_ms: int idempotent_verified: bool probe_concurrency: int structural_cluster: str = field(default="") def _param_fingerprint(params: dict) -> str: canon = "|".join(f"{k}={params[k]!r}" for k in sorted(params)) return hashlib.sha256(canon.encode()).hexdigest()[:16] def calibrate( advertised: AdvertisedContract, subtask_class: str, params: dict, dispatch_fn, probe_payload: dict, probe_concurrency: int, ) -> RealizedContract: """Probe the contractor through the *production* channel, twice, to convert the advertised contract into a realized one. The second dispatch exists solely to test the idempotency claim; an empty diff is the only evidence that retries are safe.""" fp = _param_fingerprint(params) t0 = time.monotonic() out_a = dispatch_fn(advertised.contractor_id, subtask_class, params, probe_payload) lat_a = int((time.monotonic() - t0) * 1000) out_b = dispatch_fn(advertised.contractor_id, subtask_class, params, probe_payload) idempotent = out_a == out_b if lat_a > advertised.p95_latency_ms * 3: # The advertised SLA is a population statistic; a single probe at # production concurrency blowing past 3x means the prior is unusable. raise SLAContractViolation( f"contractor={advertised.contractor_id} class={subtask_class} " f"probe_latency={lat_a}ms vs advertised_p95={advertised.p95_latency_ms}ms " f"at concurrency={probe_concurrency}; advertised contract rejected as prior" ) cluster = hashlib.sha256(repr(sorted(probe_payload)).encode()).hexdigest()[:8] return RealizedContract( contractor_id=advertised.contractor_id, subtask_class=subtask_class, param_fingerprint=fp, realized_p95_ms=lat_a, idempotent_verified=idempotent, probe_concurrency=probe_concurrency, structural_cluster=cluster, ) def decompose( advertised: AdvertisedContract, realized: RealizedContract, params: dict, payloads: list, safety_factor: float = 1.5, ) -> list: """Dispatch subtasks only under the realized contract. Asserted mode is forbidden: every subtask's SLA is derived from realized telemetry, and retries are enabled only if idempotency was verified by probe diff.""" if _param_fingerprint(params) != realized.param_fingerprint: raise SLAContractViolation( f"param drift: dispatch fingerprint {_param_fingerprint(params)} " f"!= calibrated {realized.param_fingerprint}; re-probe required" ) per_subtask_sla = max(advertised.p95_latency_ms, int(realized.realized_p95_ms * safety_factor)) max_concurrency = max(1, advertised.p95_latency_ms * realized.probe_concurrency // per_subtask_sla) plan = [] for i, payload in enumerate(payloads): cluster = hashlib.sha256(repr(sorted(payload)).encode()).hexdigest()[:8] if cluster != realized.structural_cluster: raise SLAContractViolation( f"subtask {i} payload cluster {cluster} outside calibrated " f"cluster {realized.structural_cluster}; OOD payload, re-probe before dispatch" ) plan.append({ "index": i, "sla_ms": per_subtask_sla, "retry": "idempotent" if realized.idempotent_verified else "no-retry", "concurrency_cap": max_concurrency, }) return plan ```