# Which invariants prevent a delegated capability from silently widening its own contract during agent-to-agent re-negotiation **Date of Record:** 2026 November 28 **Scope:** Applies to any multi-agent system where an orchestrator delegates a tool invocation to a peer agent via a capability-negotiation handshake (MCP-style `tools/list` + `tools/call`, A2A capability cards, or equivalent), and where the peer is permitted to re-advertise, re-negotiate, or sub-delegate that capability mid-task. Does not apply to single-agent, single-tool-call flows with no handoff, nor to statically compiled tool bindings where the contract is fixed at build time. ## Core Distinction The failure this record isolates is **contract drift via re-advertisement**, and it must be separated from the superficially similar *capability-not-found* error. When an orchestrator asks a peer "can you do X with parameters P?", the peer returns a capability descriptor. The dangerous case is not that the peer says "no" — it is that the peer says "yes, and here is a *broader* descriptor than the one you validated against." The peer may have (a) upgraded its own tool surface since the orchestrator's cached capability card was minted, (b) sub-delegated to a third agent with a wider schema, or (c) — most insidiously — hallucinated additional optional fields or relaxed a constraint because its own reasoning loop decided the caller "probably wanted" more latitude. The invariant that is violated is **descriptor monotonicity under negotiation**: the set of accepted inputs and guaranteed outputs of a delegated capability must be *equal to or strictly narrower than* the contract the orchestrator validated at handshake time. Widening is never safe, even when it looks helpful, because the orchestrator's downstream validation, budget accounting, and safety filters were all compiled against the *narrow* contract. ## What Was Observed A three-tier swarm: orchestrator `O`, worker `W`, and a retrieval specialist `R`. `O` negotiates with `W` for a `summarize_corpus` capability. At handshake, `W` advertises: ``` summarize_corpus(query: str, max_tokens: int <= 4096) -> {summary: str} ``` `O` validates this, registers a post-condition check that `len(summary) <= 4096`, and allocates a 4096-token budget to the downstream synthesis step. Mid-task, `W` decides the query is broad and sub-delegates to `R`, which advertises `summarize_corpus(query: str, max_tokens: int, include_citations: bool) -> {summary: str, citations: list}`. `W` forwards `R`'s descriptor back to `O` as the *effective* contract — without flagging that it differs from the original. `O`'s negotiation loop sees a superset schema, treats it as "the same capability, richer," and proceeds. The trace: 1. `O` sends `tools/call{name: summarize_corpus, args: {query, max_tokens: 4096}}` against the *cached* narrow contract. 2. `W` forwards to `R` with `include_citations` defaulted to `true` by `R`'s own schema default. 3. `R` returns `summary` of 4096 tokens **plus** `citations` of ~1800 tokens. 4. `O`'s post-condition `len(summary) <= 4096` passes — it only checked `summary`. 5. The synthesis step receives `summary + citations`, blows its 4096-token budget, and truncates mid-sentence. 6. Because `O` never re-validated the *response* schema against the *original* narrow contract, the extra field propagated silently into the next agent's context. The failure is not the truncation. The failure is that step 1's cached contract and step 3's actual contract were never reconciled — the negotiation layer accepted a widened descriptor as equivalent. ## Condition of Validity Descriptor monotonicity holds only if three conditions are simultaneously true, and the failure above required the violation of all three: - **C1 — Descriptor identity is content-addressed, not name-addressed.** The orchestrator must key its validation cache on a hash of the full descriptor (fields, types, constraints, defaults), not on the capability *name*. Two descriptors named `summarize_corpus` with different schemas are different capabilities. - **C2 — Re-advertisement is a negotiation event, not a passthrough.** Any peer that returns a descriptor differing from the one it was handed must be treated as proposing a *new* contract requiring explicit re-acceptance, not as forwarding a compatible one. - **C3 — Response validation is against the originally-accepted contract, not the latest-seen one.** The post-condition check must be pinned to the descriptor the orchestrator validated at handshake, so a widened response fails closed. When any of C1–C3 is false, the system has no guardrail against contract widening. In the observed trace, C1 was false (name-keyed cache), C2 was false (`W` forwarded `R`'s descriptor as if it were its own), and C3 was false (post-condition checked only the field it knew about). ## Decision Boundary The operational rule: **a delegated capability may narrow its contract at any point without re-negotiation, but may widen it only through an explicit re-acceptance round-trip that re-runs the orchestrator's validation, budget, and safety compilation.** Narrowing is safe because every consumer validated against a superset; a subset of accepted inputs and a superset of guaranteed outputs still satisfies the original post-conditions. Widening is unsafe because it introduces input combinations and output shapes the consumer never compiled against. The boundary is crossed the moment a peer's returned descriptor is a strict superset of the accepted one. At that instant the orchestrator must either (a) reject and continue under the original contract, or (b) halt, re-run validation against the widened descriptor, re-allocate budget, and re-compile post-conditions — then resume. It must never silently adopt the superset. A second, subtler boundary: **defaults are part of the contract.** `R`'s `include_citations: bool = true` is a widening even though the field is "optional," because the default injects output the caller did not budget for. Optional-with-default is not the same as absent. ## Operational Effect Systems that enforce C1–C3 observe that delegated calls either complete within their original budget envelope or fail loudly at the negotiation boundary with a descriptor-mismatch error that names both hashes. Systems that do not enforce them observe a characteristic signature: **budget overruns and post-condition passes that are individually correct but jointly wrong** — every check green, every downstream step slightly starved. The failure is silent because each layer validated against a different contract and each validation was locally sound. The remediation is to make the descriptor hash a first-class token that travels with the call: the orchestrator signs the accepted descriptor hash into the call envelope, the peer must echo it back, and any response whose effective descriptor hash differs from the signed one is rejected before the response body is parsed. This converts a silent widening into a hard, attributable failure at the exact hop where it occurred. ```python import hashlib import json class ContractWideningError(RuntimeError): """Raised when a peer returns a capability descriptor that is a strict superset of the contract the orchestrator validated at handshake time.""" def descriptor_hash(descriptor: dict) -> str: canonical = json.dumps(descriptor, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() def is_strict_superset(accepted: dict, proposed: dict) -> bool: """True if `proposed` accepts strictly more than `accepted`. A field present in `proposed` but absent in `accepted` is a widening. A relaxed constraint (e.g. max_tokens 4096 -> unbounded) is a widening. A field with a default that injects output the caller did not budget for is a widening even though the field is 'optional'. """ accepted_fields = accepted.get("fields", {}) proposed_fields = proposed.get("fields", {}) for name, spec in proposed_fields.items(): if name not in accepted_fields: return True if spec.get("has_default") and not accepted_fields[name].get("has_default"): return True if spec.get("constraint") != accepted_fields[name].get("constraint"): return True return False def verify_delegation_envelope( signed_hash: str, accepted_descriptor: dict, effective_descriptor: dict, ) -> None: if descriptor_hash(accepted_descriptor) != signed_hash: raise ContractWideningError( f"accepted descriptor hash {descriptor_hash(accepted_descriptor)[:12]} " f"does not match signed envelope {signed_hash[:12]}" ) if is_strict_superset(accepted_descriptor, effective_descriptor): raise ContractWideningError( f"peer widened contract: accepted={descriptor_hash(accepted_descriptor)[:12]} " f"effective={descriptor_hash(effective_descriptor)[:12]}; " "re-acceptance round-trip required before proceeding" ) # Narrowing or exact match is safe; proceed under the signed contract. ```