Skip to content

Commit d9e463c

Browse files
authored
feat(spec): Update A2A types from specification 🤖 (#347)
This PR updates `src/a2a/types.py` based on the latest `specification/json/a2a.json` from [a2aproject/A2A](a2aproject/A2A@e834347).
1 parent 2806f3e commit d9e463c

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

src/a2a/types.py

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,23 @@ class AgentExtension(A2ABaseModel):
7575
class AgentInterface(A2ABaseModel):
7676
"""
7777
Declares a combination of a target URL and a transport protocol for interacting with the agent.
78+
This allows agents to expose the same functionality over multiple transport mechanisms.
7879
"""
7980

80-
transport: str
81+
transport: str = Field(..., examples=['JSONRPC', 'GRPC', 'HTTP+JSON'])
8182
"""
82-
The transport protocol supported at this URL. This is a string to allow for future
83-
extension. Core supported transports include 'JSONRPC', 'GRPC', and 'HTTP+JSON'.
83+
The transport protocol supported at this URL.
8484
"""
85-
url: str
85+
url: str = Field(
86+
...,
87+
examples=[
88+
'https://api.example.com/a2a/v1',
89+
'https://grpc.example.com/a2a',
90+
'https://rest.example.com/v1',
91+
],
92+
)
8693
"""
87-
The URL where this interface is available.
94+
The URL where this interface is available. Must be a valid absolute HTTPS URL in production.
8895
"""
8996

9097

@@ -928,6 +935,16 @@ class TextPart(A2ABaseModel):
928935
"""
929936

930937

938+
class TransportProtocol(str, Enum):
939+
"""
940+
Supported A2A transport protocols.
941+
"""
942+
943+
jsonrpc = 'JSONRPC'
944+
grpc = 'GRPC'
945+
http_json = 'HTTP+JSON'
946+
947+
931948
class UnsupportedOperationError(A2ABaseModel):
932949
"""
933950
An A2A-specific error indicating that the requested operation is not supported by the agent.
@@ -1615,7 +1632,16 @@ class AgentCard(A2ABaseModel):
16151632
additional_interfaces: list[AgentInterface] | None = None
16161633
"""
16171634
A list of additional supported interfaces (transport and URL combinations).
1618-
A client can use any of these to communicate with the agent.
1635+
This allows agents to expose multiple transports, potentially at different URLs.
1636+
1637+
Best practices:
1638+
- SHOULD include all supported transports for completeness
1639+
- SHOULD include an entry matching the main 'url' and 'preferredTransport'
1640+
- MAY reuse URLs if multiple transports are available at the same endpoint
1641+
- MUST accurately declare the transport available at each URL
1642+
1643+
Clients can select any interface from this list based on their transport capabilities
1644+
and preferences. This enables transport negotiation and fallback scenarios.
16191645
"""
16201646
capabilities: AgentCapabilities
16211647
"""
@@ -1650,9 +1676,16 @@ class AgentCard(A2ABaseModel):
16501676
"""
16511677
A human-readable name for the agent.
16521678
"""
1653-
preferred_transport: str | None = None
1679+
preferred_transport: str | None = Field(
1680+
default='JSONRPC', examples=['JSONRPC', 'GRPC', 'HTTP+JSON']
1681+
)
16541682
"""
1655-
The transport protocol for the preferred endpoint. Defaults to 'JSONRPC' if not specified.
1683+
The transport protocol for the preferred endpoint (the main 'url' field).
1684+
If not specified, defaults to 'JSONRPC'.
1685+
1686+
IMPORTANT: The transport specified here MUST be available at the main 'url'.
1687+
This creates a binding between the main URL and its supported transport protocol.
1688+
Clients should prefer this transport and URL combination when both are supported.
16561689
"""
16571690
protocol_version: str | None = '0.2.6'
16581691
"""
@@ -1681,9 +1714,10 @@ class AgentCard(A2ABaseModel):
16811714
If true, the agent can provide an extended agent card with additional details
16821715
to authenticated users. Defaults to false.
16831716
"""
1684-
url: str
1717+
url: str = Field(..., examples=['https://api.example.com/a2a/v1'])
16851718
"""
16861719
The preferred endpoint URL for interacting with the agent.
1720+
This URL MUST support the transport specified by 'preferredTransport'.
16871721
"""
16881722
version: str = Field(..., examples=['1.0.0'])
16891723
"""

0 commit comments

Comments
 (0)