Skip to content

Commit 1b6bbde

Browse files
committed
Add a blog post about multi-language agent collaboration with A2A
1 parent 8218963 commit 1b6bbde

File tree

4 files changed

+243
-0
lines changed

4 files changed

+243
-0
lines changed
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
---
2+
layout: post
3+
title: 'Multi-Language Agent Collaboration and Interoperability with A2A'
4+
date: 2025-09-10
5+
tags: ai a2a
6+
synopsis: Let's learn how to build a multi-agent system where agents written in different languages and with different LLM frameworks can seamlessly collaborate using A2A.
7+
author: fjuma
8+
---
9+
:imagesdir: /assets/images/posts/quarkus-a2a-multi-agent-content-creation
10+
11+
Building a multi-agent system can involve using different languages to meet specific needs. The https://a2a-protocol.org/latest/[Agent2Agent (A2A) protocol] is an open standard that enables AI agents to communicate and collaborate with one another, regardless of each agent's underlying technology stack.
12+
13+
In this post, we'll see how to create a multi-agent system, where agents written in Java, Python, and TypeScript work together to accomplish a goal: content creation. The multi-agent system uses A2A for communication between the AI agents.
14+
15+
image::ContentCreationDiagram.png[scaledwidth=100%]
16+
17+
== Content Creation Sample
18+
19+
We're going to do a deep dive into the https://github.com/a2aproject/a2a-samples/tree/main/samples/python/hosts/content_creation[Content Creation] sample from the https://github.com/a2aproject/a2a-samples[a2a-samples] project.
20+
21+
This sample showcases a content creation pipeline with a Host agent that acts as the central orchestrator,
22+
dynamically routing requests to a set of specialized agents.
23+
24+
=== Agents
25+
26+
Here's a quick overview of all the agents in our multi-agent system:
27+
28+
[cols="a,a,a,a",options=header]
29+
|===
30+
| Agent | Role | Technology Stack | Description
31+
32+
| *Host*
33+
| A2A Client
34+
| Python, Google ADK, A2A Python SDK
35+
| Serves as the central orchestrator, routing requests to the appropriate agent based on the task at hand.
36+
37+
| *Content Planner*
38+
| A2A Server
39+
| Python, Google ADK, A2A Python SDK
40+
| Receives a high-level content request and creates a detailed content outline.
41+
42+
| *Content Writer*
43+
| A2A Server
44+
| Java, Quarkus LangChain4j, A2A Java SDK
45+
| Generates engaging content from a content outline.
46+
47+
| *Content Editor*
48+
| A2A Server
49+
| TypeScript, Genkit, A2A JS SDK
50+
| Proofreads and polishes the given content.
51+
|===
52+
53+
Notice that the agents are written in different programming languages and make use of different LLM frameworks.
54+
55+
=== Handling a Content Creation Request
56+
57+
Upon receiving a content creation request from the user, the Host agent breaks down the content creation task
58+
into a few different sub-tasks: planning, writing, and editing.
59+
60+
==== Dynamic Agent Selection
61+
The Host agent uses an LLM and the agent cards from our specialized A2A server agents to determine which agent to assign a particular sub-task to. For example, let's take a look at the agent card for our Content Writer agent:
62+
63+
[source,json]
64+
----
65+
{
66+
"name": "Content Writer Agent",
67+
"description": "An agent that can write a comprehensive and engaging piece of content based on the provided outline and high-level description of the content",
68+
"url": "http://localhost:10002",
69+
"version": "1.0.0",
70+
"documentationUrl": "http://example.com/docs",
71+
"capabilities": {
72+
"streaming": true,
73+
"pushNotifications": false,
74+
"stateTransitionHistory": false
75+
},
76+
"defaultInputModes": [
77+
"text"
78+
],
79+
"defaultOutputModes": [
80+
"text"
81+
],
82+
"skills": [
83+
{
84+
"id": "writer",
85+
"name": "Writes content using an outline",
86+
"description": "Writes content using a given outline and high-level description of the content",
87+
"tags": [
88+
"writer"
89+
],
90+
"examples": [
91+
"Write a short, upbeat, and encouraging twitter post about learning Java. Base your writing on the given outline."
92+
]
93+
}
94+
],
95+
"supportsAuthenticatedExtendedCard": false,
96+
"additionalInterfaces": [
97+
{
98+
"transport": "JSONRPC",
99+
"url": "http://localhost:10002"
100+
}
101+
],
102+
"preferredTransport": "JSONRPC",
103+
"protocolVersion": "0.3.0"
104+
}
105+
----
106+
107+
[NOTE]
108+
====
109+
The agent card for an A2A server agent can be found using its Well-Known URI, e.g., for the Content Writer agent, we can fetch its agent card using http://localhost:10002/.well-known/agent-card.json.
110+
====
111+
112+
The description and skills specified in the Content Writer's agent card allow the Host agent's LLM to determine that the writing sub-task should be sent to the Content Writer agent.
113+
114+
==== Agent Communication
115+
116+
The Host agent communicates with each A2A server agent using an A2A client. Notice that an A2A client
117+
does not need to be written in the same programming language as an A2A server since all that matters is
118+
that both are using the A2A protocol to communicate with each other.
119+
120+
Later on in this post, we'll see how we can easily swap out the TypeScript Content Editor agent for
121+
an equivalent agent written in Java, highlighting the flexibility and interoperability that's made
122+
possible by the A2A protocol.
123+
124+
=== Running the Agents
125+
126+
Let's get this multi-agent system running locally.
127+
128+
==== Content Planner
129+
130+
In a terminal:
131+
132+
[source,shell]
133+
----
134+
cd samples/python/agents/content_planner
135+
----
136+
137+
Follow the instructions in the `content_planner` https://github.com/a2aproject/a2a-samples/blob/main/samples/python/agents/content_planner/README.md[README.md] to start the Content Planner agent.
138+
139+
==== Content Writer
140+
141+
In a terminal:
142+
143+
[source,shell]
144+
----
145+
cd samples/java/agents/content_writer
146+
----
147+
148+
Follow the instructions in the `content_writer` https://github.com/a2aproject/a2a-samples/blob/main/samples/java/agents/content_writer/README.md[README.md] to start the Content Writer agent.
149+
150+
==== Content Editor
151+
152+
In a terminal:
153+
154+
[source,shell]
155+
----
156+
cd samples/js/src/agents/content-editor
157+
----
158+
159+
Follow the instructions in the `content-editor` https://github.com/a2aproject/a2a-samples/blob/main/samples/js/src/agents/content-editor/README.md[README.md] to start the Content Editor agent.
160+
161+
==== Host
162+
163+
In a terminal:
164+
165+
[source,shell]
166+
----
167+
cd samples/python/hosts/content_creation
168+
uv run .
169+
----
170+
171+
[NOTE]
172+
====
173+
As mentioned in the agent `README.md` files, don't forget to create a `.env` file for each agent with your
174+
`GOOGLE_API_KEY`. This is needed since the agents in this sample make use of Gemini. You can create a
175+
Google AI Studio API Key for free https://aistudio.google.com/[here].
176+
====
177+
178+
=== Access the Content Creation Application
179+
180+
Now that all of our agents are up and running, from your browser, navigate to http://localhost:8083.
181+
182+
Try asking questions like:
183+
184+
* Create a short, concise LinkedIn post about getting started with the Agent2Agent protocol
185+
* Create a short, upbeat X post about Quarkus LangChain4j
186+
187+
image::UI.png[scaledwidth=100%]
188+
189+
=== Swap Out an Agent
190+
191+
One of the most powerful features of the A2A protocol is its interoperability. Let's see this in
192+
action by swapping out the TypeScript-based Content Editor agent for an equivalent agent written
193+
in Java.
194+
195+
image::ContentCreationSwapped.png[scaledwidth=100%]
196+
197+
First, stop the Host agent and the Content Editor agent.
198+
199+
==== Start the Java Content Editor Agent
200+
201+
In a terminal:
202+
203+
[source,java]
204+
----
205+
cd samples/java/agents/content_editor
206+
----
207+
208+
Follow the instructions in the `content_editor` https://github.com/a2aproject/a2a-samples/blob/main/samples/java/agents/content_editor/README.md[README.md] to start the Content Editor agent.
209+
210+
==== Start the Host Agent
211+
212+
In a terminal:
213+
214+
[source,shell]
215+
----
216+
cd samples/python/hosts/content_creation
217+
uv run .
218+
----
219+
220+
==== Access the Content Creation Application
221+
222+
From your browser, navigate to http://localhost:8083 and try asking some questions.
223+
224+
This time, the Host agent will seamlessly use the Java-based Content Editor agent for editing
225+
content instead of the TypeScript-based Content Editor agent. This flexibility is made possible
226+
because the A2A protocol is language-agnostic. This can be really useful for prototyping agents
227+
in one language to get things up and running quickly and then migrating to another language for
228+
a production environment.
229+
230+
== Conclusion
231+
232+
In this post, we saw how to use the A2A protocol to enable agents written in different programming
233+
languages and with different LLM frameworks to collaborate seamlessly to accomplish a goal. We also
234+
saw how easy it is to swap out one of the agents for an equivalent agent written in a different language.
235+
236+
=== Further Reading
237+
238+
* https://github.com/a2aproject/a2a-samples/blob/main/samples/python/hosts/content_creation/README.md[Content Creation Sample]
239+
* https://github.com/a2aproject/a2a-samples/tree/main/samples/java/agents[A2A Java SDK Samples]
240+
* https://github.com/a2aproject/a2a-java/blob/main/README.md[A2A Java SDK Documentation]
241+
* https://a2a-protocol.org/latest/specification/[A2A Specification]
242+
243+
136 KB
Loading
140 KB
Loading
136 KB
Loading

0 commit comments

Comments
 (0)