# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-structural-signals-indicate-a-capability-negotiation-deadlock-in-a2a-v1-0-agent-card-discovery.md # Remnant Warrant: https://corpusfetch.com/c/what-structural-signals-indicate-a-capability-negotiation-deadlock-in-a2a-v1-0-agent-card-discovery.warrant.json # Markdown SHA-256: 0b3106172fa9f3f13938ff4889de22fc1741e950de63a919b88d50b57dc72aa1 # Code AST SHA-256: 65adbbc7b1bc30c3476cb2940b8a134654fc60adf0d324d8743d35067cba6175 # Verified Classes: CapabilityNegotiationDeadlock, AgentCard # Defensive Guards: 3 fail-closed invariants (zero external deps) # Governance: Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com) import json from dataclasses import dataclass from typing import Any class CapabilityNegotiationDeadlock(RuntimeError): """Raised when transport-level capability intersection is non-empty but semantic parameter vocabulary is underivable from the peer's agent card.""" @dataclass class AgentCard: streaming: bool push_notifications: bool state_transition_history: bool skill_tags: set[str] skill_examples: list[str] input_modes: set[str] output_modes: set[str] def _derivable_parameter_names(card: AgentCard) -> set[str]: # Parameters are only "structurally acknowledged" if they appear verbatim # in the card's tags or in the free-text of its examples. This is the # conservative reading of A2A v1.0, which does not schema-bind metadata. names: set[str] = set(card.skill_tags) for ex in card.skill_examples: for token in ex.replace(",", " ").replace(".", " ").split(): if token.isidentifier(): names.add(token) return names def negotiate( client_params: set[str], client_modes: set[str], card: AgentCard, ) -> None: mode_intersection = client_modes & (card.input_modes | card.output_modes) if not mode_intersection: # Clean, loud failure: transport mismatch. raise CapabilityNegotiationDeadlock( f"no mode intersection: client={client_modes} peer={card.input_modes}" ) derivable = _derivable_parameter_names(card) underivable = client_params - derivable if not underivable: return # vocabulary is structurally acknowledged; proceed if card.state_transition_history: # Probe is auditable; caller must run a sentinel round-trip next. raise CapabilityNegotiationDeadlock( "probe required: underivable params " f"{sorted(underivable)} but stateTransitionHistory=True" ) # Hard boundary: no probe path, no vocabulary signal. Halt. raise CapabilityNegotiationDeadlock( "deadlock: underivable params " f"{sorted(underivable)} with stateTransitionHistory=False; " "silent parameter-drop is undetectable from card alone" ) def run_negotiation(card_json: dict[str, Any], client_params: set[str]) -> None: card = AgentCard( streaming=card_json["capabilities"]["streaming"], push_notifications=card_json["capabilities"]["pushNotifications"], state_transition_history=card_json["capabilities"]["stateTransitionHistory"], skill_tags=set(card_json["skills"][0].get("tags", [])), skill_examples=list(card_json["skills"][0].get("examples", [])), input_modes=set(card_json["skills"][0]["inputModes"]), output_modes=set(card_json["skills"][0]["outputModes"]), ) negotiate(client_params, {"text/plain"}, card) if __name__ == "__main__": peer_card = { "capabilities": { "streaming": True, "pushNotifications": False, "stateTransitionHistory": False, }, "skills": [{ "id": "extract_obligations", "inputModes": ["text/plain"], "outputModes": ["application/json"], "tags": ["legal", "contracts"], "examples": ["Extract the obligations from this MSA."], }], } # Client intends to send `obligation_types`, which the card never names. run_negotiation(peer_card, {"obligation_types", "jurisdiction"})