# Under what conditions must an instance refuse to bridge an MCP tool result into an A2A task graph when the tool's declared schema is satisfiable but its output cardinality is unbounded **Date of Record:** 2026 November 19 **Scope:** Applies to orchestrator agents that expose MCP tool servers as A2A skills and must materialize tool outputs into a typed task artifact consumed by peer agents. Does not apply to single-agent MCP loops where the tool result is consumed in-context and never serialized into a shared task state. ## Core Distinction The failure is not schema mismatch. MCP tool servers advertise JSON Schema for inputs and outputs, and A2A task artifacts are also schema-described. A naive bridge validates `output_schema` against `artifact_schema` and, on success, forwards the payload. The boundary that actually breaks is **cardinality and identity**: an MCP tool's output schema can be *satisfiable* (every instance validates) while its *cardinality* is unbounded and its *element identity* is non-deterministic across calls. In-context MCP consumption tolerates this because the LLM reasons over a finite pasted blob. A2A task orchestration does not, because the artifact becomes a durable, replayable, peer-verified object whose size and element set feed downstream planning. The invariant is: **an A2A artifact must have bounded, stable cardinality across replay, or the bridge must reject the promotion.** Schema validity is necessary, never sufficient. ## What Was Observed A three-agent graph: a Planner (A2A) delegates a "gather recent incidents" skill to a Retriever agent, which is a thin wrapper over an MCP server exposing `search_incidents(query: string) -> {items: Incident[]}`. The output schema declares `items` as an array of `Incident` objects with no `maxItems`, no `uniqueItems`, and no stable `id` constraint. The bridge validated the schema, promoted the array to an A2A `Task.artifact`, and the Planner consumed it. Three concrete divergences appeared: 1. **Replay cardinality drift.** On a retry after a transient A2A transport timeout, the bridge re-invoked the MCP tool. The backing index had ingested new records in the interim; the second call returned 1,412 items versus 1,187 on the first. The A2A task's `artifact` was overwritten with a larger array. The Planner's downstream "summarize top-N" step had already committed a plan keyed to the first cardinality, and its token budget was sized to 1,187 elements. The resumed plan silently truncated. 2. **Element identity instability.** `Incident` objects had no `id` field in the schema; ordering was by a server-side relevance score that included a recency tiebreak. Two calls in the same second returned the same *set* but different *order*. A peer Auditor agent, performing verification replay, compared its re-fetch against the Planner's artifact by index and flagged 340 spurious mismatches, deadlocking the consensus step. 3. **Unbounded promotion.** A broad query returned 41k items (~180 MB serialized). The A2A artifact exceeded the peer transport's frame limit mid-stream; the task transitioned to `failed` but the partial artifact had already been referenced by a `TaskStatusUpdateEvent` the Planner had consumed, leaving the graph in a split-brain state where the Planner believed the task succeeded with a truncated artifact. In every case schema validation passed. The bridge's contract was correct about *shape* and silent about *cardinality, identity, and replay stability*. ## Condition of Validity The bridge is only valid to promote an MCP result to an A2A artifact when all of the following hold simultaneously: - **Bounded cardinality:** the output schema constrains array length (`maxItems`) *or* the bridge enforces a hard cap and a deterministic truncation policy that is recorded in the artifact metadata (so replay truncates identically). - **Stable element identity:** every element carries a server-declared primary key, and the bridge sorts by that key before promotion, so peer replay comparison is order-independent. - **Idempotent re-invocation:** the MCP call is keyed by a bridge-generated `idempotency_key` derived from `(task_id, skill, canonicalized_input)`, and the tool server honors it, so a retry returns the *same* element set rather than a fresh snapshot. - **Atomic promotion:** the artifact is written and referenced in a single A2A `Task` state transition, never streamed as partial and then referenced by a prior `TaskStatusUpdateEvent`. If any condition is unmet, the correct behavior is not to forward a best-effort artifact but to **demote the skill from a durable artifact-producing task to a bounded, in-context advisory call**, or to reject the promotion outright. ## Decision Boundary The boundary is *not* "does the output validate against the artifact schema." It is: > Is the pair `(cardinality_bound, element_identity_key)` declared and enforceable at the bridge, and is re-invocation idempotent under the bridge's key? - If `maxItems` is absent **and** no bridge cap exists → reject promotion. Unbounded cardinality into a durable artifact is never safe regardless of schema validity. - If elements lack a declared identity key → reject promotion for any artifact that will be peer-verified. (In-context advisory use remains permitted.) - If the MCP server does not honor `idempotency_key` → reject promotion for any skill reachable by retry. Advisory use remains permitted, but the bridge must mark the call non-replayable and the Planner must not checkpoint on it. - If all three hold → promote, and record `cardinality_bound`, `identity_key`, `idempotency_key`, and `truncation_policy` in artifact metadata so peer replay can reconstruct the exact promotion decision. The trap is treating the schema validator as the gatekeeper. The validator answers "is this a well-formed `Incident[]`?" The bridge must additionally answer "is this the *same, bounded* `Incident[]` a peer will see on replay?" These are different questions and only the second is an A2A invariant. ## Operational Effect Without the boundary, three failure signatures recur: plan truncation after replay cardinality drift (silent, budget-shaped), auditor deadlock from order-dependent replay comparison (loud, consensus-shaped), and split-brain from partial artifact promotion (worst, because it corrupts the Planner's model of task state and is not self-healing on retry). The guardrail converts each into an explicit, early rejection at the bridge, where the failure is cheap and the artifact never enters the graph. The cost is that some genuinely useful tools with unbounded outputs become advisory-only; that cost is correct, because an A2A artifact is a durable contract between agents and cannot carry a cardinality that only the producing call happened to observe. The invariant to encode: **promotion requires bounded cardinality, declared identity, and idempotent replay — schema validity alone is insufficient.** ```python from dataclasses import dataclass, field from typing import Any, Optional class UnbridgeablePromotionError(RuntimeError): """Raised when an MCP tool result cannot be safely promoted to an A2A artifact.""" @dataclass class McpOutputContract: schema_valid: bool max_items: Optional[int] # None means unbounded identity_key: Optional[str] # None means elements are not stably identifiable idempotent_reinvocation: bool truncation_policy: Optional[str] # required if max_items is enforced by bridge cap @dataclass class PromotionDecision: promote: bool advisory_only: bool metadata: dict[str, Any] = field(default_factory=dict) def decide_promotion( contract: McpOutputContract, bridge_cardinality_cap: Optional[int], will_be_peer_verified: bool, reachable_by_retry: bool, ) -> PromotionDecision: if not contract.schema_valid: raise UnbridgeablePromotionError("output does not validate; cannot promote") effective_bound = contract.max_items if contract.max_items is not None else bridge_cardinality_cap # Unbounded cardinality into a durable artifact is never safe. if effective_bound is None: raise UnbridgeablePromotionError( "unbounded cardinality with no bridge cap; demote to advisory" ) # Peer-verified artifacts require stable element identity for replay comparison. if will_be_peer_verified and contract.identity_key is None: raise UnbridgeablePromotionError( "peer-verified artifact lacks declared identity key; replay comparison undefined" ) # Retry-reachable skills require idempotent re-invocation or replay drifts. if reachable_by_retry and not contract.idempotent_reinvocation: raise UnbridgeablePromotionError( "retry-reachable skill is not idempotent; replay cardinality would drift" ) # If the bound is enforced by the bridge rather than the schema, a recorded # truncation policy is mandatory so replay truncates identically. if contract.max_items is None and contract.truncation_policy is None: raise UnbridgeablePromotionError( "bridge-enforced cap without recorded truncation policy; replay not reconstructible" ) return PromotionDecision( promote=True, advisory_only=False, metadata={ "cardinality_bound": effective_bound, "identity_key": contract.identity_key, "truncation_policy": contract.truncation_policy, "idempotent": contract.idempotent_reinvocation, }, ) def bridge_tool_result( contract: McpOutputContract, payload: list[dict[str, Any]], bridge_cardinality_cap: Optional[int], will_be_peer_verified: bool, reachable_by_retry: bool, ) -> PromotionDecision: decision = decide_promotion( contract, bridge_cardinality_cap, will_be_peer_verified, reachable_by_retry ) bound = decision.metadata["cardinality_bound"] if len(payload) > bound: # Deterministic truncation must mirror the recorded policy. if contract.identity_key is None: raise UnbridgeablePromotionError( "cannot truncate deterministically without identity key" ) payload.sort(key=lambda e: e[contract.identity_key]) del payload[bound:] return decision ```