build_card - AG2
build_card
autogen.beta.a2a.card.build_card
build_card(agent, *, url, transports=('jsonrpc',), rest_url=None, rest_path_prefix='', grpc_url=None, version=_DEFAULT_VERSION, description=None, push_notifications=False, skills=None, security=(), provider=None, documentation_url=None, icon_url=None, tenants=None)
Construct an AgentCard describing an AG2 agent for A2A discovery.
Always declares the urn:ag2:client-tools:v1 extension as required=False — the server can transparently fall back to a plain text exchange when the client doesn't speak the extension.
supported_interfaces is built from transports — one AgentInterface per enabled binding. JSON-RPC URL is url; REST URL defaults to url + rest_path_prefix (same host:port, different path) but can be overridden via rest_url when REST lives on a different host:port; gRPC lives on its own grpc_url.
When skills is supplied, it replaces all auto-detection. When it is None, build_card walks agent.tools for any :class:SkillsToolkit and publishes its agentskills.io-style local skills as AgentSkill entries; if none are found, falls back to a single skill derived from agent.name / agent._system_prompt so the card stays spec-compliant.
security is a sequence of :class:Requirement objects built via require(scheme, ...). Each entry is an AND-set of schemes; the list itself is OR-ed (any one requirement suffices). Underlying security_schemes on the card are auto-derived from the schemes referenced in security — no duplicate declarations needed. tenants maps a transport name to a tenant string surfaced on the corresponding AgentInterface.tenant.
Source code in autogen/beta/a2a/card.py
<br> 30<br> 31<br> 32<br> 33<br> 34<br> 35<br> 36<br> 37<br> 38<br> 39<br> 40<br> 41<br> 42<br> 43<br> 44<br> 45<br> 46<br> 47<br> 48<br> 49<br> 50<br> 51<br> 52<br> 53<br> 54<br> 55<br> 56<br> 57<br> 58<br> 59<br> 60<br> 61<br> 62<br> 63<br> 64<br> 65<br> 66<br> 67<br> 68<br> 69<br> 70<br> 71<br> 72<br> 73<br> 74<br> 75<br> 76<br> 77<br> 78<br> 79<br> 80<br> 81<br> 82<br> 83<br> 84<br> 85<br> 86<br> 87<br> 88<br> 89<br> 90<br> 91<br> 92<br> 93<br> 94<br> 95<br> 96<br> 97<br> 98<br> 99<br>100<br>101<br>102<br>103<br>104<br>105<br>106<br>107<br>108<br>109<br>110<br>111<br>112<br>113<br>114<br>115<br>116<br>117<br>118<br>119<br>120<br>121<br> |
``` def build_card( agent: Agent, *, url: str, transports: Sequence[TransportName] = ("jsonrpc",), rest_url: str |