a2a 0.1.0.pre → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.agent-docs/ROADMAP.md +423 -0
  3. data/.agent-docs/index.md +124 -0
  4. data/.agent-docs/llms.txt +318 -0
  5. data/.agent-docs/specification/json.json +2575 -0
  6. data/.agent-docs/specification.md +1924 -0
  7. data/.agent-docs/topics/a2a-and-mcp.md +132 -0
  8. data/.agent-docs/topics/agent-discovery.md +96 -0
  9. data/.agent-docs/topics/enterprise-ready.md +139 -0
  10. data/.agent-docs/topics/extensions.md +260 -0
  11. data/.agent-docs/topics/key-concepts.md +99 -0
  12. data/.agent-docs/topics/life-of-a-task.md +255 -0
  13. data/.agent-docs/topics/streaming-and-async.md +111 -0
  14. data/.agent-docs/topics/what-is-a2a.md +218 -0
  15. data/.agent-docs/tutorials/index.md +31 -0
  16. data/.agent-docs/tutorials/python/1-introduction.md +32 -0
  17. data/.agent-docs/tutorials/python/2-setup.md +55 -0
  18. data/.agent-docs/tutorials/python/3-agent-skills-and-card.md +48 -0
  19. data/.agent-docs/tutorials/python/4-agent-executor.md +57 -0
  20. data/.agent-docs/tutorials/python/5-start-server.md +55 -0
  21. data/.agent-docs/tutorials/python/6-interact-with-server.md +95 -0
  22. data/.agent-docs/tutorials/python/7-streaming-and-multiturn.md +97 -0
  23. data/.agent-docs/tutorials/python/8-next-steps.md +40 -0
  24. data/.agent-docs/types.ts +1544 -0
  25. data/.agent-docs/types_mapping.md +196 -0
  26. data/.claude/commands/gemfile/update.md +52 -0
  27. data/.claude/settings.local.json +23 -0
  28. data/.rubocop.yml +25 -4
  29. data/.tool-versions +1 -1
  30. data/CHANGELOG.md +86 -2
  31. data/CLAUDE.md +98 -0
  32. data/Guardfile +1 -1
  33. data/README.md +55 -4
  34. data/Rakefile +1 -3
  35. data/WARP.md +115 -0
  36. data/lib/a2a/extensions/additional_properties.rb +121 -0
  37. data/lib/a2a/extensions/case_transformation.rb +46 -0
  38. data/lib/a2a/extensions/json_deserialization.rb +51 -0
  39. data/lib/a2a/types/agent_capabilities.rb +18 -0
  40. data/lib/a2a/types/agent_card.rb +71 -0
  41. data/lib/a2a/types/agent_card_signature.rb +17 -0
  42. data/lib/a2a/types/agent_extension.rb +19 -0
  43. data/lib/a2a/types/agent_interface.rb +13 -0
  44. data/lib/a2a/types/agent_provider.rb +12 -0
  45. data/lib/a2a/types/agent_skill.rb +34 -0
  46. data/lib/a2a/types/api_key_security_scheme.rb +15 -0
  47. data/lib/a2a/types/artifact.rb +24 -0
  48. data/lib/a2a/types/authenticated_extended_card_not_configured_error.rb +43 -0
  49. data/lib/a2a/types/authorization_code_oauth_flow.rb +22 -0
  50. data/lib/a2a/types/cancel_task_request.rb +18 -0
  51. data/lib/a2a/types/cancel_task_response.rb +12 -0
  52. data/lib/a2a/types/client_credentials_oauth_flow.rb +16 -0
  53. data/lib/a2a/types/content_type_not_supported_error.rb +42 -0
  54. data/lib/a2a/types/data_part.rb +12 -0
  55. data/lib/a2a/types/delete_task_push_notification_config_params.rb +9 -0
  56. data/lib/a2a/types/delete_task_push_notification_config_request.rb +18 -0
  57. data/lib/a2a/types/delete_task_push_notification_config_response.rb +13 -0
  58. data/lib/a2a/types/error.rb +19 -0
  59. data/lib/a2a/types/error_codes.rb +32 -0
  60. data/lib/a2a/types/file_base.rb +12 -0
  61. data/lib/a2a/types/file_part.rb +13 -0
  62. data/lib/a2a/types/file_with_bytes.rb +9 -0
  63. data/lib/a2a/types/file_with_uri.rb +9 -0
  64. data/lib/a2a/types/get_authenticated_extended_card_request.rb +15 -0
  65. data/lib/a2a/types/get_authenticated_extended_card_response.rb +13 -0
  66. data/lib/a2a/types/get_task_push_notification_config_params.rb +9 -0
  67. data/lib/a2a/types/get_task_push_notification_config_request.rb +21 -0
  68. data/lib/a2a/types/get_task_push_notification_request.rb +18 -0
  69. data/lib/a2a/types/get_task_push_notification_response.rb +12 -0
  70. data/lib/a2a/types/get_task_request.rb +18 -0
  71. data/lib/a2a/types/get_task_response.rb +12 -0
  72. data/lib/a2a/types/http_auth_security_scheme.rb +18 -0
  73. data/lib/a2a/types/implicit_oauth_flow.rb +16 -0
  74. data/lib/a2a/types/invalid_agent_response_error.rb +41 -0
  75. data/lib/a2a/types/list_task_push_notification_config_params.rb +8 -0
  76. data/lib/a2a/types/list_task_push_notification_config_request.rb +18 -0
  77. data/lib/a2a/types/list_task_push_notification_config_response.rb +13 -0
  78. data/lib/a2a/types/message.rb +35 -0
  79. data/lib/a2a/types/message_send_configuration.rb +20 -0
  80. data/lib/a2a/types/message_send_params.rb +16 -0
  81. data/lib/a2a/types/mutual_tls_security_scheme.rb +9 -0
  82. data/lib/a2a/types/oauth2_security_scheme.rb +16 -0
  83. data/lib/a2a/types/oauth_flows.rb +20 -0
  84. data/lib/a2a/types/openid_connect_security_scheme.rb +12 -0
  85. data/lib/a2a/types/part.rb +7 -0
  86. data/lib/a2a/types/part_base.rb +9 -0
  87. data/lib/a2a/types/password_oauth_flow.rb +16 -0
  88. data/lib/a2a/types/protocol_struct.rb +12 -0
  89. data/lib/a2a/types/push_notification_authentication_info.rb +12 -0
  90. data/lib/a2a/types/push_notification_config.rb +20 -0
  91. data/lib/a2a/types/push_notification_not_supported_error.rb +42 -0
  92. data/lib/a2a/types/request.rb +15 -0
  93. data/lib/a2a/types/security_scheme.rb +11 -0
  94. data/lib/a2a/types/security_scheme_base.rb +9 -0
  95. data/lib/a2a/types/send_message_request.rb +18 -0
  96. data/lib/a2a/types/send_message_response.rb +13 -0
  97. data/lib/a2a/types/send_streaming_message_request.rb +18 -0
  98. data/lib/a2a/types/send_streaming_message_response.rb +15 -0
  99. data/lib/a2a/types/set_task_push_notification_config_request.rb +18 -0
  100. data/lib/a2a/types/set_task_push_notification_request.rb +18 -0
  101. data/lib/a2a/types/set_task_push_notification_response.rb +12 -0
  102. data/lib/a2a/types/task.rb +29 -0
  103. data/lib/a2a/types/task_artifact_update_event.rb +29 -0
  104. data/lib/a2a/types/task_id_params.rb +12 -0
  105. data/lib/a2a/types/task_not_cancelable_error.rb +42 -0
  106. data/lib/a2a/types/task_not_found_error.rb +42 -0
  107. data/lib/a2a/types/task_push_notification_config.rb +12 -0
  108. data/lib/a2a/types/task_query_params.rb +9 -0
  109. data/lib/a2a/types/task_resubscription_request.rb +18 -0
  110. data/lib/a2a/types/task_state.rb +7 -0
  111. data/lib/a2a/types/task_status.rb +15 -0
  112. data/lib/a2a/types/task_status_update_event.rb +25 -0
  113. data/lib/a2a/types/text_part.rb +12 -0
  114. data/lib/a2a/types/transport_protocol.rb +6 -0
  115. data/lib/a2a/types/unsupported_operation_error.rb +42 -0
  116. data/lib/a2a/types.rb +25 -0
  117. data/lib/a2a/version.rb +1 -1
  118. data/lib/a2a.rb +30 -1
  119. metadata +128 -299
@@ -0,0 +1,132 @@
1
+ # A2A and MCP: Detailed Comparison
2
+
3
+ In AI agent development, two key protocol types emerge to facilitate
4
+ interoperability. One connects agents to tools and resources. The other enables
5
+ agent-to-agent collaboration. The Agent2Agent (A2A) Protocol and the
6
+ [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) address these distinct but highly complementary needs.
7
+
8
+ ## Model Context Protocol
9
+
10
+ The Model Context Protocol (MCP) defines how an AI agent interacts with and utilizes individual tools and resources, such as a database or an API.
11
+
12
+ This protocol offers the following capabilities:
13
+
14
+ - Standardizes how AI models and agents connect to and interact with tools,
15
+ APIs, and other external resources.
16
+ - Defines a structured way to describe tool capabilities, similar to function
17
+ calling in Large Language Models.
18
+ - Passes inputs to tools and receives structured outputs.
19
+ - Supports common use cases, such as an LLM calling an external API, an agent
20
+ querying a database, or an agent connecting to predefined functions.
21
+
22
+ ## Agent2Agent Protocol
23
+
24
+ The Agent2Agent Protocol focuses on enabling different agents to collaborate with one another to achieve a common goal.
25
+
26
+ This protocol offers the following capabilities:
27
+
28
+ - Standardizes how independent, often opaque, AI agents communicate and
29
+ collaborate as peers.
30
+ - Provides an application-level protocol for agents to discover each other,
31
+ negotiate interactions, manage shared tasks, and exchange conversational
32
+ context and complex data.
33
+ - Supports typical use cases, including a customer service agent delegating an
34
+ inquiry to a billing agent, or a travel agent coordinating with flight,
35
+ hotel, and activity agents.
36
+
37
+ ## Why Different Protocols?
38
+
39
+ Both the MCP and A2A protocols are essential for building complex AI systems, and they address distinct but highly complementary needs. The distinction between A2A and MCP depends on what an agent interacts with.
40
+
41
+ - **Tools and Resources (MCP Domain)**:
42
+ - **Characteristics:** These are typically primitives with well-defined,
43
+ structured inputs and outputs. They perform specific, often stateless,
44
+ functions. Examples include a calculator, a database query API, or a
45
+ weather lookup service.
46
+ - **Purpose:** Agents use tools to gather information and perform discrete
47
+ functions.
48
+ - **Agents (A2A domain)**:
49
+ - **Characteristics:** These are more autonomous systems. They reason,
50
+ plan, use multiple tools, maintain state over longer interactions, and
51
+ engage in complex, often multi-turn dialogues to achieve novel or
52
+ evolving tasks.
53
+ - **Purpose:** Agents collaborate with other agents to tackle broader, more
54
+ complex goals.
55
+
56
+ ## A2A ❤️ MCP: Complementary Protocols for Agentic Systems
57
+
58
+ An agentic application might primarily use A2A to communicate with other agents.
59
+ Each individual agent internally uses MCP to interact with its specific tools
60
+ and resources.
61
+
62
+ <div style="text-align: center; margin: 20px;" markdown>
63
+
64
+ ![Diagram showing A2A and MCP working together. A User interacts with Agent A using A2A. Agent A interacts with Agent B using A2A. Agent B uses MCP to interact with Tool 1 and Tool 2.](../assets/a2a-mcp.png){width="80%"}
65
+
66
+ _An agentic application might use A2A to communicate with other agents, while each agent internally uses MCP to interact with its specific tools and resources._
67
+
68
+ </div>
69
+
70
+ ### Example Scenario: The Auto Repair Shop
71
+
72
+ Consider an auto repair shop staffed by autonomous AI agent "mechanics".
73
+ These mechanics use special-purpose tools, such as vehicle diagnostic scanners,
74
+ repair manuals, and platform lifts, to diagnose and repair problems. The repair
75
+ process can involve extensive conversations, research, and interaction with part
76
+ suppliers.
77
+
78
+ - **Customer Interaction (User-to-Agent using A2A)**: A customer (or their
79
+ primary assistant agent) uses A2A to communicate with the "Shop Manager"
80
+ agent.
81
+
82
+ For example, the customer might say, "My car is making a rattling noise".
83
+
84
+ - **Multi-turn Diagnostic Conversation (Agent-to-Agent using A2A)**: The Shop
85
+ Manager agent uses A2A for a multi-turn diagnostic conversation.
86
+
87
+ For example, the Manager might ask, "Can you send a video of the noise?" or "I see some fluid leaking. How long has this been happening?".
88
+
89
+ - **Internal Tool Usage (Agent-to-Tool using MCP)**: The Mechanic agent,
90
+ assigned the task by the Shop Manager, needs to diagnose the issue. The
91
+ Mechanic agent uses MCP to interact with its specialized tools.
92
+
93
+ For example:
94
+
95
+ - MCP call to a "Vehicle Diagnostic Scanner" tool:
96
+ `scan_vehicle_for_error_codes(vehicle_id='XYZ123')`
97
+ - MCP call to a "Repair Manual Database" tool:
98
+ `get_repair_procedure(error_code='P0300', vehicle_make='Toyota',
99
+ vehicle_model='Camry')`
100
+ - MCP call to a "Platform Lift" tool: `raise_platform(height_meters=2)`
101
+
102
+ - **Supplier Interaction (Agent-to-Agent using A2A)**: The Mechanic agent
103
+ determines that a specific part is needed. The Mechanic agent uses A2A to
104
+ communicate with a "Parts Supplier" agent to order a part.
105
+ For example, the
106
+ Mechanic agent might ask, "Do you have part #12345 in stock for a Toyota Camry 2018?"
107
+
108
+ - **Order processing (Agent-to-Agent using A2A)**: The Parts Supplier agent,
109
+ which is also an A2A-compliant system, responds, potentially leading to an
110
+ order.
111
+
112
+ In this example:
113
+
114
+ - A2A facilitates the higher-level, conversational, and task-oriented
115
+ interactions between the customer and the shop, and between the shop's
116
+ agents and external supplier agents.
117
+ - MCP enables the mechanic agent to use its specific, structured tools to
118
+ perform its diagnostic and repair functions.
119
+
120
+ An A2A server could expose some of its skills as MCP-compatible resources.
121
+ However, A2A's primary strength lies in its support for more flexible, stateful,
122
+ and collaborative interactions. These interactions go beyond a typical tool
123
+ invocation. A2A focuses on agents partnering on tasks, whereas MCP focuses on
124
+ agents using capabilities.
125
+
126
+ ## Representing A2A Agents as MCP Resources
127
+
128
+ An A2A Server (a remote agent) could expose some of its skills as MCP-compatible resources, especially if those skills are well-defined and can be invoked in a more tool-like, stateless manner. In such a case, another agent might "discover" this A2A agent's specific skill through an MCP-style tool description (perhaps derived from its Agent Card).
129
+
130
+ However, the primary strength of A2A lies in its support for more flexible, stateful, and collaborative interactions that go beyond typical tool invocation. A2A is about agents _partnering_ on tasks, while MCP is more about agents _using_ capabilities.
131
+
132
+ By leveraging both A2A for inter-agent collaboration and MCP for tool integration, developers can build more powerful, flexible, and interoperable AI systems.
@@ -0,0 +1,96 @@
1
+ # Agent Discovery in A2A
2
+
3
+ To collaborate using the Agent2Agent (A2A) protocol, AI agents need to first find each other and understand their capabilities. A2A standardizes agent self-descriptions through the **[Agent Card](../specification.md#5-agent-discovery-the-agent-card)**. However, discovery methods for these Agent Cards vary by environment and requirements. The Agent Card defines what an agent offers. Various strategies exist for a client agent to discover these cards. The choice of strategy depends on the deployment environment and security requirements.
4
+
5
+ ## The Role of the Agent Card
6
+
7
+ The Agent Card is a JSON document that serves as a digital "business card" for an A2A Server (the remote agent). It is crucial for agent discovery and interaction. The key information included in an Agent Card is as follows:
8
+
9
+ - **Identity:** Includes `name`, `description`, and `provider` information.
10
+ - **Service Endpoint:** Specifies the `url` for the A2A service.
11
+ - **A2A Capabilities:** Lists supported features such as `streaming` or `pushNotifications`.
12
+ - **Authentication:** Details the required `schemes` (e.g., "Bearer", "OAuth2").
13
+ - **Skills:** Describes the agent's tasks using `AgentSkill` objects, including `id`, `name`, `description`, `inputModes`, `outputModes`, and `examples`.
14
+
15
+ Client agents use the Agent Card to determine an agent's suitability, structure requests, and ensure secure communication.
16
+
17
+ ## Discovery Strategies
18
+
19
+ The following sections detail common strategies used by client agents to discover remote Agent Cards:
20
+
21
+ ### 1. Well-Known URI
22
+
23
+ This approach is recommended for public agents or agents intended for broad discovery within a specific domain.
24
+
25
+ - **Mechanism:** A2A Servers make their Agent Card discoverable by hosting it at a standardized, `well-known` URI on their domain. The standard path is `https://{agent-server-domain}/.well-known/agent-card.json`, following the principles of [RFC 8615](https://datatracker.ietf.org/doc/html/rfc8615).
26
+
27
+ - **Process:**
28
+ 1. A client agent knows or programmatically discovers the domain of a potential A2A Server (e.g., `smart-thermostat.example.com`).
29
+ 2. The client performs an HTTP GET request to `https://smart-thermostat.example.com/.well-known/agent-card.json`.
30
+ 3. If the Agent Card exists and is accessible, the server returns it as a JSON response.
31
+
32
+ - **Advantages:**
33
+ - Ease of implementation
34
+ - Adheres to standards
35
+ - Facilitates automated discovery
36
+
37
+ - **Considerations:**
38
+ - Best suited for open or domain-controlled discovery scenarios.
39
+ - Authentication is necessary at the endpoint serving the Agent Card if it contains sensitive details.
40
+
41
+ ### 2. Curated Registries (Catalog-Based Discovery)
42
+
43
+ This approach is employed in enterprise environments or public marketplaces, where Agent Cards are often managed by a central registry. The curated registry acts as a central repository, allowing clients to query and discover agents based on criteria like "skills" or "tags".
44
+
45
+ - **Mechanism:** An intermediary service (the registry) maintains a collection of Agent Cards. Clients query this registry to find agents based on various criteria (e.g., skills offered, tags, provider name, capabilities).
46
+
47
+ - **Process:**
48
+ 1. A2A Servers publish their Agent Cards to the registry.
49
+ 2. Client agents query the registry's API, and search by criteria such as "specific skills".
50
+ 3. The registry returns matching Agent Cards or references.
51
+
52
+ - **Advantages:**
53
+ - Centralized management and governance.
54
+ - Capability-based discovery (e.g., by skill).
55
+ - Support for access controls and trust frameworks.
56
+ - Applicable in both private and public marketplaces.
57
+ - **Considerations:**
58
+ - Requires deployment and maintenance of a registry service.
59
+ - The current A2A specification does not prescribe a standard API for curated registries.
60
+
61
+ ### 3. Direct Configuration / Private Discovery
62
+
63
+ This approach is used for tightly coupled systems, private agents, or development purposes, where clients are directly configured with Agent Card information or URLs.
64
+
65
+ - **Mechanism:** Client applications utilize hardcoded details, configuration files, environment variables, or proprietary APIs for discovery.
66
+ - **Process:** The process is specific to the application's deployment and configuration strategy.
67
+ - **Advantages:** This method is straightforward for establishing connections within known, static relationships.
68
+ - **Considerations:**
69
+ - Inflexible for dynamic discovery scenarios.
70
+ - Changes to Agent Card information necessitate client reconfiguration.
71
+ - Proprietary API-based discovery also lacks standardization.
72
+
73
+ ## Securing Agent Cards
74
+
75
+ Agent Cards include sensitive information, such as:
76
+
77
+ - URLs for internal or restricted agents.
78
+ - Descriptions of sensitive skills.
79
+
80
+ ### Protection Mechanisms
81
+
82
+ To mitigate risks, the following protection mechanisms should be considered:
83
+
84
+ - **Authenticated Agent Cards:** We recommend the use of [authenticated extended agent cards](../specification.md#710-agentgetauthenticatedextendedcard) for sensitive information or for serving a more detailed version of the card.
85
+ - **Secure Endpoints:** Implement access controls on the HTTP endpoint serving the Agent Card (e.g., `/.well-known/agent-card.json` or registry API). The methods include:
86
+ - Mutual TLS (mTLS)
87
+ - Network restrictions (e.g., IP ranges)
88
+ - HTTP Authentication (e.g., OAuth 2.0)
89
+
90
+ - **Registry Selective Disclosure:** Registries return different Agent Cards based on the client's identity and permissions.
91
+
92
+ Any Agent Card containing sensitive data must be protected with authentication and authorization mechanisms. The A2A specification strongly recommends the use of out-of-band dynamic credentials rather than embedding static secrets within the Agent Card.
93
+
94
+ ## Future Considerations
95
+
96
+ The A2A community explores standardizing registry interactions or advanced discovery protocols.
@@ -0,0 +1,139 @@
1
+ # Enterprise Implementation of A2A
2
+
3
+ The Agent2Agent (A2A) protocol is designed with enterprise requirements at its
4
+ core. Rather than inventing new, proprietary standards for security and
5
+ operations, A2A aims to integrate seamlessly with existing enterprise
6
+ infrastructure and widely adopted best practices. This approach allows
7
+ organizations to use their existing investments and expertise in security,
8
+ monitoring, governance, and identity management.
9
+
10
+ A key principle of A2A is that agents are typically **opaque** because they don't
11
+ share internal memory, tools, or direct resource access with each other. This
12
+ opacity naturally aligns with standard client-server security paradigms,
13
+ treating remote agents as standard HTTP-based enterprise applications.
14
+
15
+ ## Transport Level Security (TLS)
16
+
17
+ Ensuring the confidentiality and integrity of data in transit is fundamental for
18
+ any enterprise application.
19
+
20
+ - **HTTPS Mandate**: All A2A communication in production environments must
21
+ occur over `HTTPS`.
22
+ - **Modern TLS Standards**: Implementations should use modern TLS versions.
23
+ TLS 1.2 or higher is recommended. Strong, industry-standard cipher suites
24
+ should be used to protect data from eavesdropping and tampering.
25
+ - **Server Identity Verification**: A2A clients should verify the A2A server's
26
+ identity by validating its TLS certificate against trusted certificate
27
+ authorities during the TLS handshake. This prevents man-in-the-middle
28
+ attacks.
29
+
30
+ ## Authentication
31
+
32
+ A2A delegates authentication to standard web mechanisms. It primarily relies on
33
+ HTTP headers and established standards like OAuth2 and OpenID Connect.
34
+ Authentication requirements are advertised by the A2A server in its Agent Card.
35
+
36
+ - **No Identity in Payload**: A2A protocol payloads, such as `JSON-RPC`
37
+ messages, don't carry user or client identity information directly. Identity
38
+ is established at the transport/HTTP layer.
39
+ - **Agent Card Declaration**: The A2A server's Agent Card describes the
40
+ authentication schemes it supports in its `security` field and aligns with
41
+ those defined in the OpenAPI Specification for authentication.
42
+ - **Out-of-Band Credential Acquisition**: The A2A Client obtains the necessary credentials,
43
+ such as OAuth 2.0 tokens or API keys, through processes external to the A2A protocol itself. Examples include OAuth flows or secure key distribution.
44
+ - **HTTP Header Transmission**: Credentials **must** be transmitted in standard
45
+ HTTP headers as per the requirements of the chosen authentication scheme.
46
+ Examples include `Authorization: Bearer <TOKEN>` or `API-Key: <KEY_VALUE>`.
47
+ - **Server-Side Validation**: The A2A server **must** authenticate every
48
+ incoming request using the credentials provided in the HTTP headers.
49
+ - If authentication fails or credentials are missing, the server **should**
50
+ respond with a standard HTTP status code:
51
+ - `401 Unauthorized`: If the credentials are missing or invalid. This
52
+ response **should** include a `WWW-Authenticate` header to inform
53
+ the client about the supported authentication methods.
54
+ - `403 Forbidden`: If the credentials are valid, but the authenticated
55
+ client does not have permission to perform the requested action.
56
+ - **In-Task Authentication (Secondary Credentials)**: If an agent needs
57
+ additional credentials to access a different system or service during a
58
+ task (for example, to use a specific tool on the user's behalf), the A2A server
59
+ indicates to the client that more information is needed. The client
60
+ is then responsible for obtaining these secondary credentials through a
61
+ process outside of the A2A protocol itself (for example, an OAuth flow) and
62
+ providing them back to the A2A server to continue the task.
63
+
64
+ ## Authorization
65
+
66
+ Once a client is authenticated, the A2A server is responsible for authorizing
67
+ the request. Authorization logic is specific to the agent's implementation,
68
+ the data it handles, and applicable enterprise policies.
69
+
70
+ - **Granular Control**: Authorization **should** be applied based on the
71
+ authenticated identity, which could represent an end user, a client
72
+ application, or both.
73
+ - **Skill-Based Authorization**: Access can be controlled on a per-skill
74
+ basis, as advertised in the Agent Card. For example, specific OAuth scopes
75
+ **should** grant an authenticated client access to invoke certain skills but
76
+ not others.
77
+ - **Data and Action-Level Authorization**: Agents that interact with backend
78
+ systems, databases, or tools **must** enforce appropriate authorization before
79
+ performing sensitive actions or accessing sensitive data through those
80
+ underlying resources. The agent acts as a gatekeeper.
81
+ - **Principle of Least Privilege**: Agents **must** grant only the necessary
82
+ permissions required for a client or user to perform their intended
83
+ operations through the A2A interface.
84
+
85
+ ## Data Privacy and Confidentiality
86
+
87
+ Protecting sensitive data exchanged between agents is paramount, requiring
88
+ strict adherence to privacy regulations and best practices.
89
+
90
+ - **Sensitivity Awareness**: Implementers must be acutely aware of the
91
+ sensitivity of data exchanged in Message and Artifact parts of A2A
92
+ interactions.
93
+ - **Compliance**: Ensure compliance with relevant data privacy regulations
94
+ such as GDPR, CCPA, and HIPAA, based on the domain and data involved.
95
+ - **Data Minimization**: Avoid including or requesting unnecessarily sensitive
96
+ information in A2A exchanges.
97
+ - **Secure Handling**: Protect data both in transit, using TLS as mandated,
98
+ and at rest if persisted by agents, according to enterprise data security
99
+ policies and regulatory requirements.
100
+
101
+ ## Tracing, Observability, and Monitoring
102
+
103
+ A2A's reliance on HTTP allows for straightforward integration with standard
104
+ enterprise tracing, logging, and monitoring tools, providing critical visibility
105
+ into inter-agent workflows.
106
+
107
+ - **Distributed Tracing**: A2A Clients and Servers **should** participate in
108
+ distributed tracing systems. For example, use OpenTelemetry to propagate
109
+ trace context, including trace IDs and span IDs, through standard HTTP
110
+ headers, such as W3C Trace Context headers. This enables end-to-end
111
+ visibility for debugging and performance analysis.
112
+ - **Comprehensive Logging**: Log details on both client and server, including
113
+ taskId, sessionId, correlation IDs, and trace context for troubleshooting
114
+ and auditing.
115
+ - **Metrics**: A2A servers should expose key operational metrics, such as
116
+ request rates, error rates, task processing latency, and resource
117
+ utilization, to enable performance monitoring, alerting, and capacity
118
+ planning.
119
+ - **Auditing**: Audit significant events, such as task creation, critical
120
+ state changes, and agent actions, especially when involving sensitive data
121
+ or high-impact operations.
122
+
123
+ ## API Management and Governance
124
+
125
+ For A2A servers exposed externally, across organizational boundaries, or even within
126
+ large enterprises, integration with API Management solutions is highly recommended,
127
+ as this provides:
128
+
129
+ - **Centralized Policy Enforcement**: Consistent application of security
130
+ policies such as authentication and authorization, rate limiting, and quotas.
131
+ - **Traffic Management**: Load balancing, routing, and mediation.
132
+ - **Analytics and Reporting**: Insights into agent usage, performance, and
133
+ trends.
134
+ - **Developer Portals**: Facilitate discovery of A2A-enabled agents, provide
135
+ documentation such as Agent Cards, and streamline onboarding for client developers.
136
+
137
+ By adhering to these enterprise-grade practices, A2A implementations can be
138
+ deployed securely, reliably, and manageably within complex organizational
139
+ environments. This fosters trust and enables scalable inter-agent collaboration.
@@ -0,0 +1,260 @@
1
+ # Extensions in A2A
2
+
3
+ The Agent2Agent (A2A) protocol provides a strong foundation for inter-agent
4
+ communication. However, specific domains or advanced use cases often require
5
+ additional structure, custom data, or new interaction patterns beyond the
6
+ generic methods. Extensions are A2A's powerful mechanism for layering new capabilities onto the
7
+ base protocol.
8
+
9
+ Extensions allow for extending the A2A protocol with new data, requirements,
10
+ RPC methods, and state machines. Agents declare their support for specific
11
+ extensions in their Agent Card, and clients can then opt-in to the behavior
12
+ offered by an extension as part of requests they make to the agent. Extensions
13
+ are identified by a URI and defined by their own specification. Anyone is able to define, publish, and implement an extension.
14
+
15
+ The flexibility of extensions allows for customizing A2A without fragmenting
16
+ the core standard, fostering innovation and domain-specific optimizations.
17
+
18
+ ## Scope of Extensions
19
+
20
+ The exact set of possible ways to use extensions is intentionally broad,
21
+ facilitating the ability to expand A2A beyond known use cases.
22
+ However, some foreseeable applications include:
23
+
24
+ - **Data-only Extensions**: Exposing new, structured information in the Agent
25
+ Card that doesn't impact the request-response flow. For example, an
26
+ extension could add structured data about an agent's GDPR compliance.
27
+ - **Profile Extensions**: Overlaying additional structure and state change
28
+ requirements on the core request-response messages. This type effectively
29
+ acts as a profile on the core A2A protocol, narrowing the space of allowed
30
+ values (for example, requiring all messages to use `DataParts` adhering to
31
+ a specific schema). This can also include augmenting existing states in the
32
+ task state machine by using metadata. For example, an extension could define
33
+ a 'generating-image' sub-state when `TaskStatus.state` is 'working' and
34
+ `TaskStatus.message.metadata["generating-image"]` is true.
35
+ - **Method Extensions (Extended Skills)**: Adding entirely new RPC methods
36
+ beyond the core set defined by the protocol. An Extended Skill refers to a
37
+ capability or function an agent gains or exposes specifically through the
38
+ implementation of an extension that defines new RPC methods. For example, a
39
+ `task-history` extension might add a `tasks/search` RPC method to retrieve
40
+ a list of previous tasks, effectively providing the agent with a new,
41
+ extended skill.
42
+ - **State Machine Extensions**: Adding new states or transitions to the task
43
+ state machine.
44
+
45
+ ## Limitations
46
+
47
+ There are some changes to the protocol that extensions don't allow, primarily
48
+ to prevent breaking core type validations:
49
+
50
+ - **Changing the Definition of Core Data Structures**: For example, adding new
51
+ fields or removing required fields to protocol-defined data structures).
52
+ Extensions should place custom attributes in the `metadata` map present on
53
+ core data structures.
54
+ - **Adding New Values to Enum Types**: Extensions should use existing enum values
55
+ and annotate additional semantic meaning in the `metadata` field.
56
+
57
+ ## Extension Declaration
58
+
59
+ Agents declare their support for extensions in their Agent Card by including
60
+ `AgentExtension` objects within their `AgentCapabilities` object.
61
+
62
+ ```ts { .no-copy }
63
+ --8<-- "types/src/types.ts:AgentExtension"
64
+ ```
65
+
66
+ The following is an example of an Agent Card with an extension:
67
+
68
+ ```json
69
+ {
70
+ "name": "Magic 8-ball",
71
+ "description": "An agent that can tell your future... maybe.",
72
+ "version": "0.1.0",
73
+ "url": "https://example.com/agents/eightball",
74
+ "capabilities": {
75
+ "streaming": true,
76
+ "extensions": [
77
+ {
78
+ "uri": "https://example.com/ext/konami-code/v1",
79
+ "description": "Provide cheat codes to unlock new fortunes",
80
+ "required": false,
81
+ "params": {
82
+ "hints": [
83
+ "When your sims need extra cash fast",
84
+ "You might deny it, but we've seen the evidence of those cows."
85
+ ]
86
+ }
87
+ }
88
+ ]
89
+ },
90
+ "defaultInputModes": ["text/plain"],
91
+ "defaultOutputModes": ["text/plain"],
92
+ "skills": [
93
+ {
94
+ "id": "fortune",
95
+ "name": "Fortune teller",
96
+ "description": "Seek advice from the mystical magic 8-ball",
97
+ "tags": ["mystical", "untrustworthy"]
98
+ }
99
+ ]
100
+ }
101
+ ```
102
+
103
+ ## Required Extensions
104
+
105
+ While extensions generally offer optional functionality, some agents may have
106
+ stricter requirements. When an Agent Card declares an extension as
107
+ `required: true`, it signals to clients that some aspect of the extension impacts how
108
+ requests are structured or processed, and that the client must abide by it.
109
+ Agents shouldn't mark data-only extensions as required. If a client does not
110
+ request activation of a required extension, or fails to follow its protocol,
111
+ the agent should reject the incoming request with an appropriate error.
112
+
113
+ ## Extension Specification
114
+
115
+ The detailed behavior and structure of an extension are defined by its
116
+ **specification**. While the exact format is not mandated, it should contain at
117
+ at least:
118
+
119
+ - The specific URI(s) that identify the extension.
120
+ - The schema and meaning of objects specified in the `params` field of the
121
+ `AgentExtension` object.
122
+ - Schemas of any additional data structures communicated between client and
123
+ agent.
124
+ - Details of new request-response flows, additional endpoints, or any other
125
+ logic required to implement the extension.
126
+
127
+ ## Extension Dependencies
128
+
129
+ Extensions might depend on other extensions. This can be a required dependency
130
+ (where the extension cannot function without the dependent) or an optional one
131
+ (where additional functionality is enabled if another extension is present).
132
+ Extension specifications should document these dependencies. It is the client's
133
+ responsibility to activate an extension and all its required dependencies as
134
+ listed in the extension's specification.
135
+
136
+ ## Extension Activation
137
+
138
+ Extensions default to being inactive, providing a baseline
139
+ experience for extension-unaware clients. Clients and agents perform
140
+ negotiation to determine which extensions are active for a specific request.
141
+
142
+ 1. **Client Request**: A client requests extension activation by including the
143
+ `X-A2A-Extensions` header in the HTTP request to the agent. The value is a
144
+ comma-separated list of extension URIs the client intends to activate.
145
+ 2. **Agent Processing**: Agents are responsible for identifying supported
146
+ extensions in the request and performing the activation. Any requested
147
+ extensions not supported by the agent can be ignored.
148
+ 3. **Response**: Once the agent has identified all activated extensions, the
149
+ response SHOULD include the `X-A2A-Extensions` header, listing all
150
+ extensions that were successfully activated for that request.
151
+
152
+ ![A2A Extension Flow Diagram](https://storage.googleapis.com/gweb-developer-goog-blog-assets/images/Screenshot_2025-09-04_at_13.03.31.original.png){ width="70%" style="margin:20px auto;display:block;" }
153
+
154
+ **Example request showing extension activation:**
155
+
156
+ ```http
157
+ POST /agents/eightball HTTP/1.1
158
+ Host: example.com
159
+ Content-Type: application/json
160
+ X-A2A-Extensions: https://example.com/ext/konami-code/v1
161
+ Content-Length: 519
162
+ {
163
+ "jsonrpc": "2.0",
164
+ "method": "message/send",
165
+ "id": "1",
166
+ "params": {
167
+ "message": {
168
+ "kind": "message",
169
+ "messageId": "1",
170
+ "role": "user",
171
+ "parts": [{"kind": "text", "text": "Oh magic 8-ball, will it rain today?"}]
172
+ },
173
+ "metadata": {
174
+ "https://example.com/ext/konami-code/v1/code": "motherlode"
175
+ }
176
+ }
177
+ }
178
+ ```
179
+
180
+ **Corresponding response echoing activated extensions:**
181
+
182
+ ```http
183
+ HTTP/1.1 200 OK
184
+ Content-Type: application/json
185
+ X-A2A-Extensions: https://example.com/ext/konami-code/v1
186
+ Content-Length: 338
187
+ {
188
+ "jsonrpc": "2.0",
189
+ "id": "1",
190
+ "result": {
191
+ "kind": "message",
192
+ "messageId": "2",
193
+ "role": "agent",
194
+ "parts": [{"kind": "text", "text": "That's a bingo!"}]
195
+ }
196
+ }
197
+ ```
198
+
199
+ ## Implementation Considerations
200
+
201
+ While the A2A protocol defines the functionality of extensions, this section
202
+ provides guidance on their implementation—best practices for authoring,
203
+ versioning, and distributing extension implementations.
204
+
205
+ - **Versioning**: Extension specifications evolve. It is
206
+ crucial to have a clear versioning strategy to ensure that clients and
207
+ agents can negotiate compatible implementations.
208
+ - **Recommendation**: Use the extension's URI as the primary version
209
+ identifier, ideally including a version number (for example,
210
+ `https://example.com/ext/my-extension/v1`).
211
+ - **Breaking Changes**: A new URI MUST be used when introducing a breaking
212
+ change to an extension's logic, data structures, or required parameters.
213
+ - Handling Mismatches: If a client requests a version not supported by
214
+ the agent, the agent SHOULD ignore the activation request for that
215
+ extension; it MUST NOT fall back to a different version.
216
+ - **Discoverability and Publication**:
217
+ - **Specification Hosting**: The extension specification document **should** be
218
+ hosted at the extension's URI.
219
+ - **Permanent Identifiers**: Authors are encouraged to use a permanent
220
+ identifier service, such as `w3id.org`, for their extension URIs to
221
+ prevent broken links.
222
+ - **Community Registry (Future)**: The A2A community might establish a
223
+ central registry for discovering and browsing available extensions in
224
+ the future.
225
+ - **Packaging and Reusability (A2A SDKs and Libraries)**:
226
+ To promote adoption, extension logic should be packaged into reusable
227
+ libraries that can be integrated into existing A2A client and
228
+ server applications.
229
+ - An extension implementation should be distributed as a
230
+ standard package for its language ecosystem (for example, a PyPI package
231
+ for Python, an npm package for TypeScript/JavaScript).
232
+ - The objective is to provide a streamlined integration experience for
233
+ developers. A well-designed extension package should allow a developer
234
+ to add it to their server with minimal code, for example:
235
+
236
+ ```python
237
+ --8<-- "https://raw.githubusercontent.com/a2aproject/a2a-samples/refs/heads/main/samples/python/agents/adk_expense_reimbursement/__main__.py"
238
+ ```
239
+
240
+ This example showcases how A2A SDKs or libraries such as `a2a.server` in
241
+ Python facilitate the implementation of A2A agents and extensions.
242
+
243
+ - **Security**: Extensions modify the core behavior of the A2A protocol, and therefore
244
+ introduce new security considerations:
245
+
246
+ - **Input Validation**: Any new data fields, parameters, or methods
247
+ introduced by an extension MUST be rigorously validated. Treat all
248
+ extension-related data from an external party as untrusted input.
249
+ - **Scope of Required Extensions**: Be mindful when marking an extension as
250
+ `required: true` in an Agent Card. This creates a hard dependency for
251
+ all clients and should only be used for extensions fundamental to the
252
+ agent's core function and security (for example, a message signing
253
+ extension).
254
+ - **Authentication and Authorization**: If an extension adds new methods,
255
+ the implementation MUST ensure these methods are subject to the same
256
+ authentication and authorization checks as the core A2A methods. An
257
+ extension MUST NOT provide a way to bypass the agent's primary security
258
+ controls.
259
+
260
+ For more information, see the [A2A Extensions: Empowering Custom Agent Functionality](https://developers.googleblog.com/en/a2a-extensions-empowering-custom-agent-functionality/) blog post.