agent_card_utils.py
1 """ 2 Utility functions for working with A2A Agent Cards. 3 """ 4 5 from typing import Optional, Dict, Tuple 6 from a2a.types import AgentCard 7 8 from .constants import EXTENSION_URI_SCHEMAS 9 10 11 def get_schemas_from_agent_card( 12 agent_card: Optional[AgentCard], 13 ) -> Tuple[Optional[Dict], Optional[Dict]]: 14 """ 15 Extract input and output schemas from an agent card's extensions. 16 17 Args: 18 agent_card: The agent card to extract schemas from 19 20 Returns: 21 Tuple of (input_schema, output_schema). Either or both may be None. 22 """ 23 if ( 24 not agent_card 25 or not agent_card.capabilities 26 or not agent_card.capabilities.extensions 27 ): 28 return None, None 29 30 for ext in agent_card.capabilities.extensions: 31 if ext.uri == EXTENSION_URI_SCHEMAS: 32 params = ext.params or {} 33 return params.get("input_schema"), params.get("output_schema") 34 35 return None, None