|
|
ADK Agent-to-Agent Communication (A2A)
Author: Venkata Sudhakar
Agent-to-Agent (A2A) communication is the pattern where one ADK agent delegates a specific sub-task to another specialised agent via a structured call, rather than trying to handle everything itself. Unlike sub-agents in a pipeline, A2A agents operate as independent services with defined input/output contracts - making them independently testable, replaceable, and composable into larger workflows.
ShopMax India uses an orchestrator agent that receives complex customer requests and routes specific tasks to specialist agents: a pricing agent, an inventory agent, and a shipping agent. Each specialist returns a structured response. The orchestrator combines the results and delivers a unified answer to the customer, with each specialist agent maintainable by a different team.
The below example shows how to build three ShopMax India specialist agents and an orchestrator that calls them via structured A2A delegation.
It gives the following output,
Specialist agents initialised: pricing, inventory, shipping
pricing_agent : gemini-2.0-flash | JSON pricing responses
inventory_agent : gemini-2.0-flash | JSON stock responses
shipping_agent : gemini-2.0-flash | JSON shipping responses
Shared session service ready for A2A calls
The below example shows the orchestrator agent that receives a ShopMax India customer query, calls all three specialist agents in parallel, and synthesises a unified response.
It gives the following output,
[A2A] Calling pricing_agent, inventory_agent, shipping_agent in parallel...
[A2A] All 3 specialist agents responded in 1.2s
Here is the complete information for your Samsung 55" QLED TV order to Pune:
Price:
List price: Rs 89,999 | Active discount: 8% | Final price: Rs 82,799
Availability:
In stock at Pune warehouse (14 units). Also available in Mumbai and Bangalore.
Delivery to Pune:
Standard (Free) - 3-4 business days
Express (Rs 299) - Next business day
Same Day (Rs 599) - Available for Pune PIN codes 411001-411057
Recommendation: Choose Express delivery (Rs 299) for next-day arrival.
Total with Express: Rs 83,098
The A2A pattern gives ShopMax India a composable agent architecture where pricing, inventory, and shipping logic evolve independently. Teams can upgrade or replace any specialist agent without touching the orchestrator, and parallel execution ensures the combined response is no slower than the slowest single specialist call - typically under 2 seconds for all three combined.
|
|