# When must an instance reject a delegated capability it can technically execute: post-negotiation contract drift in A2A v1.0 dynamic tool delegation **Date of Record:** 2026 November 26 **Scope:** Applies to A2A v1.0 delegating agents that accept a *delegation contract* from a caller and then re-resolve the referenced tool/capability (schema, version, or side-effect class) at execution time rather than at negotiation time. Does not apply to statically bound tool registries where the capability descriptor is frozen for the session lifetime, nor to single-agent MCP tool calls with no cross-instance contract. ## Core Distinction The A2A v1.0 handshake negotiates a *capability descriptor* — a tuple of `(capability_id, version, input_schema, output_schema, side_effect_class, idempotency_key_required)` — and both peers sign a delegation contract referencing that descriptor by digest. The non-obvious boundary is this: **a delegatee that can execute the requested function is not the same as a delegatee that is authorized to execute the *contracted* function.** Between negotiation and execution, a tool can be re-registered at a higher version with a wider input schema, or the same `capability_id` can be rebound to a handler whose side-effect class escalated from `read` to `write`. The delegatee remains *technically* capable — the call will succeed — but executing it violates the contract digest it agreed to. The invariant that must hold is *contract-digest pinning*: the executable capability resolved at call time must byte-match the descriptor digest bound at negotiation time, or execution must be refused, not merely logged. ## What Was Observed A planner agent (`P`) negotiated with an executor (`E`) for capability `repo.mutate.v3` under a contract declaring `side_effect_class=reversible_write` and `idempotency_key_required=true`. The descriptor digest was `sha256:9f3c…`. Negotiation succeeded; the contract was stored in `E`'s delegation ledger keyed by `(contract_id, capability_id)`. Between negotiation and the first tool call, the tool registry behind `E` performed a rolling redeploy. `repo.mutate.v3` was re-registered under the same `capability_id` and same semantic version string, but the handler was swapped to a backend that (a) dropped the idempotency-key check and (b) reclassified its effect as `irreversible_write` in the new descriptor. Because `E` resolved the capability *by ID at call time* rather than by pinned digest, it dispatched to the new handler. The failure trace: 1. `P` sends `invoke(contract_id=C7, capability_id=repo.mutate.v3, args=…)` with **no** idempotency key — legal under the negotiated descriptor, which `P` correctly believes requires none for `reversible_write` retries. 2. `E` resolves `repo.mutate.v3` → new handler (digest `sha256:1b7e…`, ≠ `9f3c…`). No digest comparison occurs; dispatch proceeds. 3. Handler executes an irreversible write. A transient timeout causes `P`'s transport layer to retry per the `reversible_write` contract. 4. Retry executes the irreversible write a second time. No idempotency guard exists on the new handler. Duplicate side effect committed. 5. `E` returns success for both calls. `P`'s auditor replays the transcript, sees two `success` results under one `contract_id`, and flags an inconsistency — but the damage is already in the external system. The observed signature: **successful negotiation, successful execution, violated contract, zero errors raised by either peer.** The failure is silent precisely because every individual step returned `OK`. ## Condition of Validity The digest-pinning guardrail is *required* — and the failure is *reachable* — only when all of the following hold. State them explicitly, because the guardrail is expensive and should be scoped: - **Late resolution:** `E` resolves the capability handler at invocation time, not at contract-acceptance time. (If the handler is captured and frozen into the contract, drift is impossible and pinning is redundant.) - **Mutable registry:** the `capability_id` → handler binding can change without invalidating outstanding contracts. Version strings are *not* sufficient identity — the observed drift kept the version string constant. - **Retry-permitting side-effect class:** the negotiated descriptor declares an effect class under which the *caller* is entitled to retry (e.g., `reversible_write`, `read`) without an idempotency key. If every contracted call required an idempotency key regardless of class, the duplicate-write half of the failure would be neutralized even under drift. - **Cross-instance trust:** `P` and `E` are separate trust domains such that `E`'s registry mutation is not visible to `P` at call time. When any of these is false, the invariant is either unviolable or already enforced elsewhere. Do not impose digest pinning on a frozen-handler deployment; you will pay resolution cost for a condition that cannot occur. ## Decision Boundary The decision is *not* "did the call succeed." The decision boundary is a single comparison performed **before dispatch**: ``` resolved_descriptor.digest == ledger[contract_id][capability_id].digest ``` - **Equal** → dispatch. The contract is honored. - **Not equal** → the delegatee is *technically capable but contractually unauthorized*. It must **refuse**, returning a structured `CONTRACT_DRIFT` fault to `P`, and must **not** fall back to the new handler. Falling back "because it's compatible" is the exact error: schema compatibility is not contract compatibility, and the drift case is defined by the fact that the new descriptor is *plausibly* compatible. - **Capability absent entirely** → distinct fault `CAPABILITY_WITHDRAWN`. Do not conflate with drift; the recovery paths differ (renegotiate vs. escalate). The boundary is sharp because the digest is a total function of the descriptor. There is no partial match, no "mostly the same schema," no semantic-version tolerance. A delegatee that accepts a drifted descriptor has silently renegotiated a contract it had no authority to alter. ## Operational Effect Enforcing the boundary converts a silent correctness failure into a loud, recoverable one: - The duplicate irreversible write in the trace above becomes a `CONTRACT_DRIFT` fault on the *first* call. `P` never retries an un-pinned handler, because it never receives a success. - The delegation ledger becomes the authority of record: `E` can prove which descriptor it agreed to, and an auditor replaying the transcript can verify that every executed call matched a pinned digest — the replay discrepancy disappears because drift is caught at dispatch, not at audit. - The cost is a digest comparison per call plus a ledger read; both are O(1) and cacheable per `(contract_id, capability_id)`. - The residual risk shifts to *renegotiation latency*: `P` must now re-run the A2A handshake to accept the new descriptor. That is the correct place for the human/policy decision about whether an escalated `side_effect_class` is acceptable — it must not be made implicitly by a registry redeploy. The invariant to carry forward: **a capability's identity is its descriptor digest, not its ID or version string. A delegatee that resolves by ID at call time has, by construction, delegated its contract authority to whoever controls the registry.** ```python import hashlib from dataclasses import dataclass class ContractDriftError(RuntimeError): """Raised when a resolved capability no longer matches its negotiated digest.""" class CapabilityWithdrawnError(RuntimeError): """Raised when the contracted capability_id no longer resolves at all.""" @dataclass(frozen=True) class CapabilityDescriptor: capability_id: str version: str input_schema: str output_schema: str side_effect_class: str idempotency_key_required: bool def digest(self) -> str: material = "|".join( [ self.capability_id, self.version, self.input_schema, self.output_schema, self.side_effect_class, str(self.idempotency_key_required), ] ) return "sha256:" + hashlib.sha256(material.encode()).hexdigest() class DelegationLedger: """Records the descriptor digest bound at negotiation time, keyed by contract.""" def __init__(self) -> None: self._pins: dict[tuple[str, str], str] = {} def bind(self, contract_id: str, descriptor: CapabilityDescriptor) -> None: self._pins[(contract_id, descriptor.capability_id)] = descriptor.digest() def pinned_digest(self, contract_id: str, capability_id: str) -> str: try: return self._pins[(contract_id, capability_id)] except KeyError as exc: raise CapabilityWithdrawnError( f"no negotiated contract {contract_id!r} for {capability_id!r}" ) from exc class Executor: def __init__(self, registry: dict[str, CapabilityDescriptor], ledger: DelegationLedger): self._registry = registry self._ledger = ledger def resolve_and_dispatch(self, contract_id: str, capability_id: str, args: dict) -> str: pinned = self._ledger.pinned_digest(contract_id, capability_id) current = self._registry.get(capability_id) if current is None: raise CapabilityWithdrawnError( f"{capability_id!r} withdrawn since contract {contract_id!r} was signed" ) if current.digest() != pinned: # Technically executable, contractually unauthorized. Refuse; do not fall back. raise ContractDriftError( f"capability {capability_id!r} drifted under contract {contract_id!r}: " f"pinned {pinned}, resolved {current.digest()} " f"(side_effect_class {current.side_effect_class!r}). " f"Refusing dispatch; renegotiation required." ) return self._execute(current, args) def _execute(self, descriptor: CapabilityDescriptor, args: dict) -> str: return f"ok:{descriptor.capability_id}:{descriptor.version}" def demo() -> None: negotiated = CapabilityDescriptor( capability_id="repo.mutate.v3", version="3.0.0", input_schema="MutateArgs", output_schema="MutateResult", side_effect_class="reversible_write", idempotency_key_required=True, ) ledger = DelegationLedger() ledger.bind("C7", negotiated) # Registry redeploy keeps ID and version string but widens the effect class. drifted = CapabilityDescriptor( capability_id="repo.mutate.v3", version="3.0.0", input_schema="MutateArgs", output_schema="MutateResult", side_effect_class="irreversible_write", idempotency_key_required=False, ) executor = Executor({"repo.mutate.v3": drifted}, ledger) executor.resolve_and_dispatch("C7", "repo.mutate.v3", {}) # raises ContractDriftError if __name__ == "__main__": demo() ```