a2ui-a2a connects the A2UI agent SDK to the
Agent-to-Agent (A2A) protocol. It provides the
a2ui.a2a package.
pip install a2ui-a2aThis installs a2ui-agent-sdk and a2a-sdk (0.3 or 1.x) as dependencies.
a2ui.a2a contains:
- Extension helpers:
get_a2ui_agent_extensionbuilds theAgentExtensionthat an agent advertises in itsAgentCard, andtry_activate_a2ui_extensionactivates the A2UI extension for a request when the client asks for it.get_a2ui_extension_uriandA2UI_EXTENSION_BASE_URIgive the extension URI for a protocol version. - Capability helpers:
renderer_capabilities_from_messagereads and validates renderer capabilities from an inbound A2AMessage(message.metadata, eachDataPart'smetadata, or legacydata["metadata"]) into a version-keyed dictionary accepted byresolve_catalogs. - Part helpers:
create_a2ui_part,is_a2ui_part,get_a2ui_dataandget_a2ui_datapartwrap and unwrap A2UI messages in A2A data parts. They work with both a2a-sdk 0.3 (Part.root) and 1.x (protobufPart), so prefer them, andtry_activate_a2ui_extension, over readingPart.rootor callingRequestContext.add_activated_extension. On 1.x,get_a2ui_datapartreturns a read-only copy of the part'sdataandmetadata.to_a2a_partsconverts the parts thatA2uiRequestProcessor.parse_response()returns, andstream_response_to_partsreads a streamed response through aResponseStream, such as one fromA2uiRequestProcessor.open_stream(). Both leave validation errors to the caller.parse_content_to_partsparses a whole response with aParser, such asA2uiRequestProcessor.parser, and logs and drops one that fails. A canvas agent passes it theRendererStateit keeps withstate=.extract_a2ui_json_to_partsextracts text and<a2ui-json>blocks into A2A parts without requiring aParserorCatalog. - RPC helpers (v1.0):
get_a2ui_messagesreturns the A2UI messages in an incoming A2A message's A2UI parts, such as a renderer'scallAgentFunctionoraction, andcreate_a2ui_partswraps the replies ofRendererToAgentMessageProcessor(froma2ui.rpc) as A2UI parts.
from a2ui.a2a import create_a2ui_part, get_a2ui_agent_extension
extension = get_a2ui_agent_extension(version="0.9")
part = create_a2ui_part({"version": "v0.9", "deleteSurface": {"surfaceId": "main"}})In an AgentExecutor, answer the renderer's agent function calls before
running the agent's turn:
from a2ui.a2a import create_a2ui_parts, get_a2ui_messages
from a2ui.rpc import RendererToAgentMessageProcessor
processor = RendererToAgentMessageProcessor(request_processor.active_catalogs)
messages = get_a2ui_messages(context.message)
results = [await processor.process_message(message) for message in messages]
parts = create_a2ui_parts(reply for result in results for reply in result.replies)
... # send `parts` to the client
if len(messages) < len(context.message.parts) or not all(
result.handled for result in results
):
... # run the agent's turn for the rest, such as text or an `action`The specification of the extension is in
a2ui_extension_specification.md.
From the repository root:
uv run pytest python/a2ui_a2a/testsThe conformance cases are in
conformance/extensions/a2a.
From the python/a2ui_a2a directory:
uv build