How does an instance detect a stale Agent Card during A2A v1.0 task lifecycle negotiation across vendors

**Date of Record:** 2026 December 1 **Scope:** Applies to A2A v1.0 peers that discover remote agents via Agent Card fetch and then open a task lifecycle (`tasks/send`, `tasks/get`, `tasks/sendSubscribe`) against the discovered endpoint. Does not apply to intra-process agent calls, MCP tool invocation, or peers using a shared registry that guarantees atomic card-to-endpoint binding.

Core Distinction

There are two failure classes that look identical in logs but require opposite remediations:

  1. **Discovery failure** — the Agent Card could not be fetched or parsed. The caller knows it does not have a valid capability contract and should not proceed.
  2. **Card–endpoint skew** — the Agent Card was fetched successfully, parsed cleanly, and *was true at fetch time*. But between discovery and task negotiation (or between two tasks in the same session), the remote instance redeployed, rotated its capability set, changed its authentication scheme, or migrated its task store. The caller is now negotiating a lifecycle against an endpoint whose live contract no longer matches the cached card.

The non-obvious invariant: **a syntactically valid, freshly-fetched Agent Card is not evidence that the endpoint will honor it at negotiation time.** A2A v1.0 defines the card as a discovery artifact, not a lease. Nothing in the protocol binds the card's `capabilities`, `skills`, `securitySchemes`, or `defaultInputModes` to the server's runtime behavior for the life of a task. Cross-vendor deployments exploit this gap constantly because their redeploy cadence is invisible to the caller.

The second-order distinction that makes this hard: the failure does not surface as a discovery error. It surfaces as a *task-lifecycle* error — a `-32601` method-not-found on `tasks/sendSubscribe` because the peer's new version dropped streaming, or a `-32001` task-not-found because the peer migrated its task store and your `contextId` no longer resolves, or a schema-validation rejection because the peer tightened `inputModes` after you cached the card. The caller misattributes all of these to its own request construction.

What Was Observed

A cross-vendor orchestration instance (`client-A`, v1.0) discovered a remote planning agent (`planner-B`) at 09:14:02Z. The fetched card declared:

`client-A` cached the card with a 24-hour TTL and opened a streaming task at 09:14:05Z. The task ran for 41 minutes, emitting incremental `TaskStatusUpdateEvent`s. At 09:55:11Z `planner-B` was redeployed (rolling, blue/green) to a build that:

`client-A` did not re-fetch. At 09:55:40Z it attempted a *second* task in the same `contextId` via `tasks/sendSubscribe`. The new build returned HTTP 200 with a JSON-RPC error body `-32601 Method not found` for the streaming method — but the error was wrapped in a `Task` envelope with `status.state: "failed"` and a `status.message` that read like a normal task failure, not a protocol-level rejection. `client-A`'s retry logic saw `state: "failed"` and re-issued the *same* streaming request three times, each returning the same wrapped error. The circuit breaker tripped at 09:56:02Z and marked `planner-B` unhealthy — but the health check it used was the *cached* card's `capabilities.streaming: true`, so the health probe kept passing while every real task failed.

The compounding failure: `client-A` then attempted to resume the *original* 41-minute task via `tasks/get` with the original `taskId`. The migrated `planner-B` returned `-32001 Task not found`. `client-A` interpreted this as task eviction and replayed the entire task from scratch, duplicating 41 minutes of planning work and emitting a second `contextId` branch that the auditor later flagged as a fork.

Three distinct observable signatures, all rooted in the same skew:

| Signature | Wire form | Caller misattribution | |---|---|---| | Capability withdrawal | `-32601` wrapped in `Task{state:"failed"}` | "task failed, retry" | | Skill rename | `-32602 Invalid params` on `message.parts` | "my payload is malformed" | | Store migration | `-32001 Task not found` | "task evicted, replay" |

Condition of Validity

The skew is *only* detectable — and the guardrail only *only* sound — under these conditions:

  1. **The caller must treat the Agent Card as a versioned, expiring assertion, not a constant.** A card with no `version` field change and no `ETag`/`Last-Modified` movement is not evidence of stability; many vendors serve cards from a CDN edge that caches for minutes after origin redeploy.
  2. **The caller must correlate every task-lifecycle error against a *re-fetched* card before classifying it as a task-level failure.** Precisely: on any `-32601`, `-32602`, or `-32001`, re-fetch the card, diff `capabilities`, `skills[].id`, `securitySchemes`, and `inputModes`, and only then decide whether the error is the caller's fault or the peer's drift.
  3. **The caller must bind `contextId` and `taskId` to a card fingerprint at task creation, and refuse to resume across a fingerprint change** without an explicit reconciliation step. A `taskId` is only meaningful relative to the peer build that issued it.
  4. **The guardrail does not hold if the peer serves a stale card from a cache longer than the caller's re-fetch interval.** In that case the caller must fall back to behavioral probing (a no-op `tasks/get` against a known task, or a `message/send` ping) rather than trusting the re-fetched card.

If any of (1)–(4) is false, the caller is in the skew window and every lifecycle error is ambiguous.

Decision Boundary

The boundary is: **does the caller treat a task-lifecycle error as authoritative about the task, or as a hypothesis to be tested against the peer's current contract?**

Below the boundary (unsafe): the caller maps wire errors directly to retry/replay/fail decisions. This is the default behavior of most A2A client SDKs, because the SDK has no notion of card freshness — it holds a `RemoteAgent` object constructed from the card at discovery and never re-validates.

Above the boundary (safe): the caller maintains a **card fingerprint** (hash of `version`, `capabilities`, sorted `skills[].id`, `securitySchemes` keys, `inputModes`) captured at task creation, and on any lifecycle error:

The decision boundary is sharp because the two branches require *opposite* actions on the same wire signal. A `-32001` under an unchanged fingerprint means replay; under a changed fingerprint it means *do not replay* — the task store moved and replaying will duplicate side effects. Getting this backwards is the entire failure.

Operational Effect

When the boundary is respected, the observable behavior changes in four ways:

  1. **Replay storms are eliminated.** The 41-minute duplicate plan in the incident becomes a single reconciliation event with an explicit fork record. The auditor sees one `contextId` with a `superseded_by` link, not two parallel branches.
  2. **Circuit breakers key on fingerprint, not on card fields.** The breaker for `planner-B` opens when the *fingerprint* changes and the peer fails reconciliation, not when a cached `capabilities.streaming: true` probe passes. The health probe is re-derived from the live card on every probe cycle.
  3. **Error classification becomes deterministic.** `-32601` is no longer "task failed, retry"; it is "capability withdrawn, re-negotiate." The retry budget is not consumed by protocol-level rejections, so genuine transient failures retain their full budget.
  4. **The cost is bounded and explicit.** Each lifecycle error triggers one card re-fetch. Under a flapping peer this is a re-fetch per error; the guardrail must cap re-fetches per `contextId` per minute and fall back to behavioral probing, or it becomes a self-inflicted DoS on the peer's discovery endpoint.

The residual risk that cannot be engineered away: if the peer serves a card that is *already stale at origin* (a misconfigured deploy that ships the old card with the new binary), no caller-side fingerprint check will detect the skew. The only defense is behavioral probing — issue a `tasks/get` against a task the peer is known to have issued and confirm it resolves — which trades latency for correctness and must be reserved for high-stakes resumptions.

import hashlib
import json
from dataclasses import dataclass


class AgentCardSkewError(RuntimeError):
    """Raised when a task-lifecycle error coincides with a changed Agent Card fingerprint."""


@dataclass(frozen=True)
class CardFingerprint:
    version: str
    capabilities: tuple
    skill_ids: tuple
    security_scheme_keys: tuple
    input_modes: tuple

    @classmethod
    def from_card(cls, card: dict) -> "CardFingerprint":
        caps = card.get("capabilities", {})
        return cls(
            version=str(card.get("version", "")),
            capabilities=tuple(sorted((k, bool(v)) for k, v in caps.items())),
            skill_ids=tuple(sorted(s.get("id", "") for s in card.get("skills", []))),
            security_scheme_keys=tuple(sorted(card.get("securitySchemes", {}).keys())),
            input_modes=tuple(sorted(card.get("defaultInputModes", []))),
        )

    def digest(self) -> str:
        blob = json.dumps(self.__dict__, sort_keys=True).encode()
        return hashlib.sha256(blob).hexdigest()[:16]


def classify_lifecycle_error(
    wire_error_code: int,
    task_fingerprint: CardFingerprint,
    live_card: dict,
) -> str:
    """Classify a task-lifecycle error as genuine vs. card-endpoint skew.

    Returns 'genuine' or 'skew'. Raises AgentCardSkewError when the caller
    is about to replay across a fingerprint change, which is the unsafe action.
    """
    if wire_error_code not in (-32601, -32602, -32001):
        return "genuine"

    live_fp = CardFingerprint.from_card(live_card)
    if live_fp.digest() == task_fingerprint.digest():
        return "genuine"

    # Fingerprint changed: the peer redeployed under us. Replaying here would
    # duplicate side effects against a migrated task store.
    if wire_error_code == -32001:
        raise AgentCardSkewError(
            f"task-not-found under changed card fingerprint "
            f"{task_fingerprint.digest()} -> {live_fp.digest()}; "
            f"refusing replay, enter reconciliation"
        )
    return "skew"


def resume_task(task_id: str, task_fingerprint: CardFingerprint, live_card: dict) -> None:
    # Caller attempted tasks/get; peer returned -32001.
    classify_lifecycle_error(-32001, task_fingerprint, live_card)