# Under what conditions must an instance distrust a dynamically resolved capability descriptor after registry-mediated discovery **Date of Record:** 2026 November 27 **Scope:** Applies to agent-to-agent (A2A) capability discovery where an orchestrator resolves a remote agent's declared capabilities (tool schemas, supported MIME types, auth scopes, protocol version) from a registry or `.well-known` descriptor and then invokes it over HTTP. Does not apply to statically compiled client stubs or to in-process tool calls where the schema is bound at build time. ## Core Distinction A capability descriptor is a *claim*, not a *contract*. When an agent resolves a peer through a dynamic registry, the descriptor it receives is a point-in-time snapshot produced by a process it does not control, transported over a channel it does not authenticate end-to-end, and cached in a layer (the registry) whose invalidation semantics are usually weaker than the peer's own deployment cadence. The failure is not "the peer lied." The failure is that **the descriptor's validity window and the peer's actual runtime schema can diverge silently**, and the orchestrator has no signal distinguishing a stale-but-well-formed descriptor from a fresh one. A descriptor that parses cleanly, carries a plausible `updated_at`, and returns HTTP 200 is indistinguishable at the transport layer from one that describes a deployment that was rolled back four minutes ago. The invariant that must hold for safe use: *a descriptor is only trustworthy for invocation if the orchestrator can bind it to the specific peer instance it will actually talk to, at the moment of invocation, not the moment of discovery.* Registry-mediated discovery breaks this binding by design—it resolves an identity, not an instance. ## What Was Observed An orchestrator agent (`O`) queried a registry (`R`) for a summarization peer. `R` returned a descriptor for agent `summarizer-v2` advertising `capabilities.tools = ["summarize", "extract_entities"]`, `input_schema` requiring `{"text": string, "max_tokens": integer}`, and `protocol_version = "1.3"`. `O` cached the descriptor with a 15-minute TTL and began issuing calls. Mid-run, `summarizer-v2` was redeployed at 1.4. The new build renamed the field `max_tokens` to `max_output_tokens` and dropped `extract_entities` (moved to a sibling agent). The registry's own record still pointed at the old descriptor because the peer's registration heartbeat had not yet fired; the registry served the stale entry with a `Cache-Control: max-age=900` that `O` honored. The failure trace: 1. `O` calls `summarize` with `{"text": ..., "max_tokens": 512}`. The peer's 1.4 handler does not recognize `max_tokens`; depending on its validation strictness it either ignores it (silently applying a default of 256) or returns `400 Unprocessable`. 2. In the *silent-ignore* branch, `O` receives a well-formed 200 response whose length is half what it budgeted for. No error surfaces. The orchestrator's downstream token accounting is now wrong, and it has no reason to suspect the peer. 3. In the *400* branch, `O`'s retry logic treats it as a transient failure, backs off, retries three times, then escalates to a fallback peer—burning the budget and misattributing the fault to the network. 4. `O` calls `extract_entities` on the same peer. The peer returns `404 Not Found` on the route. `O`'s descriptor said the capability existed; its own routing table is now internally inconsistent with observed reality. The critical observation: **step 2 is the dangerous one.** A hard 400/404 is recoverable; a silent schema-drift that returns a plausible response is not, because it poisons the orchestrator's state without raising. The registry never emitted an invalidation event, the peer never advertised a version bump in a header, and the descriptor's `updated_at` field was still the old deployment's timestamp. ## Condition of Validity Distrust of a resolved descriptor is *required*—not merely advisable—when all three of the following hold: - **Identity is registry-scoped, not instance-scoped.** The descriptor is keyed by a logical name (`summarizer-v2`) rather than a content-addressed or instance-bound identifier (a deployment hash, a build ID echoed in a response header, or a signed descriptor whose signature the peer re-asserts at call time). If you cannot re-derive "is this the same instance I discovered?" from the invocation response, the binding is broken. - **The peer's schema is mutable independently of the registry's record.** If the peer can redeploy without the registry observing it—i.e., registration is push-heartbeat rather than pull-verified—there is always a window where the registry's view lags reality. The window length is `heartbeat_interval + cache_ttl`, and it is unbounded if the heartbeat can fail silently. - **The capability carries semantic payloads whose misinterpretation is non-fatal to the transport.** If a schema mismatch always produces a hard error (strict validation, required-field enforcement), the transport layer catches it. Distrust is mandatory precisely when the peer's validation is permissive enough that a drifted call *succeeds with wrong semantics*. Distrust is *not* required when the descriptor is cryptographically bound to the instance (the peer signs responses with a key whose fingerprint matches the descriptor), or when the protocol mandates a per-call schema-negotiation handshake that fails closed. ## Decision Boundary The boundary is between **resolve-then-invoke** and **negotiate-then-invoke**. Resolve-then-invoke is safe only under the closed-world assumption that the registry is authoritative and the peer cannot change without the registry knowing. In any open multi-tenant deployment, that assumption fails. The operational rule: > A descriptor resolved from a registry may be used to *select* a peer, but must not be used to *construct* a request payload until the peer has confirmed the schema for this specific invocation. Concretely, the orchestrator must, before the first call to a newly resolved peer (and periodically thereafter, or on any 4xx/5xx), issue a lightweight capability-confirmation call—a `GET /capabilities` on the peer's own endpoint, or a protocol-level `describe`—and compare the returned schema hash against the registry's. If they differ, the registry entry is stale and must be treated as untrusted for payload construction, even though it remains valid for peer selection. The comparison is cheap; the silent-drift failure it prevents is not. The second boundary: any response that *succeeds* but whose shape does not match the confirmed schema (missing fields the schema required, a field type that drifted, a response length that contradicts a caller-supplied bound) must be treated as a **schema-drift signal**, not as a valid result. The orchestrator should quarantine the peer's descriptor, invalidate the cache entry, and re-negotiate—rather than accepting the response and continuing. ## Operational Effect Without this boundary, the orchestrator's state accumulates silent corruption: token budgets mis-accounted, entity-extraction calls routed to peers that no longer implement them, retry storms against transient-looking-but-actually-structural errors. The corruption is invisible until a downstream aggregation produces an obviously wrong result, at which point the causal chain back to the stale descriptor is unrecoverable from logs—because the stale descriptor was never logged as suspect. With the boundary enforced, the failure mode becomes loud and local: the first drifted call triggers a schema-hash mismatch, the peer is quarantined, the registry entry is flagged stale, and the orchestrator re-resolves. The cost is one extra round-trip per newly resolved peer and a hash comparison per response; the benefit is that schema drift can never masquerade as a successful call. The invariant to encode: **a descriptor's authority extends to peer selection, never to payload construction, unless the peer re-asserts the schema at invocation time.** Any orchestrator that conflates the two is one redeploy away from silent, unlogged state corruption. ```python import hashlib from dataclasses import dataclass class DescriptorDriftError(RuntimeError): """Raised when a resolved capability descriptor no longer matches the peer's actual schema.""" @dataclass(frozen=True) class CapabilityDescriptor: peer_id: str schema: dict protocol_version: str def schema_hash(self) -> str: canonical = repr(sorted(self.schema.items())).encode() return hashlib.sha256(canonical).hexdigest() def build_invocation_payload( resolved: CapabilityDescriptor, live: CapabilityDescriptor, payload: dict, ) -> dict: """ Guard: a registry-resolved descriptor may select a peer, but the payload must be constructed against the schema the peer re-asserts at call time. """ if resolved.peer_id != live.peer_id: raise DescriptorDriftError( f"identity mismatch: registry={resolved.peer_id} live={live.peer_id}" ) if resolved.schema_hash() != live.schema_hash(): raise DescriptorDriftError( "schema drift between registry descriptor and live peer; " "quarantine peer and re-negotiate before constructing payload" ) unknown = set(payload) - set(live.schema.get("properties", {})) if unknown: raise DescriptorDriftError( f"payload fields not in live schema: {sorted(unknown)}" ) return payload def validate_response(resolved: CapabilityDescriptor, response: dict) -> None: """A 200 response whose shape contradicts the confirmed schema is drift, not success.""" required = set(resolved.schema.get("required", [])) missing = required - set(response) if missing: raise DescriptorDriftError( f"successful response missing required fields: {sorted(missing)}" ) ```