Skip to content

Commit dd0d917

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

File tree

4 files changed

+248
-0
lines changed

4 files changed

+248
-0
lines changed
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
---
2+
layout: post
3+
title: 'Multi-Language Agent Collaboration and Interoperability with A2A'
4+
date: 2025-09-15
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+
This is to demonstrate what's possible with the A2A protocol.
55+
56+
=== Handling a Content Creation Request
57+
58+
Upon receiving a content creation request from the user, the `Host` agent breaks down the content creation task
59+
into a few different sub-tasks: planning, writing, and editing.
60+
61+
==== Dynamic Agent Selection
62+
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:
63+
64+
[source,json]
65+
----
66+
{
67+
"name": "Content Writer Agent",
68+
"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",
69+
"url": "http://localhost:10002",
70+
"version": "1.0.0",
71+
"documentationUrl": "http://example.com/docs",
72+
"capabilities": {
73+
"streaming": true,
74+
"pushNotifications": false,
75+
"stateTransitionHistory": false
76+
},
77+
"defaultInputModes": [
78+
"text"
79+
],
80+
"defaultOutputModes": [
81+
"text"
82+
],
83+
"skills": [
84+
{
85+
"id": "writer",
86+
"name": "Writes content using an outline",
87+
"description": "Writes content using a given outline and high-level description of the content",
88+
"tags": [
89+
"writer"
90+
],
91+
"examples": [
92+
"Write a short, upbeat, and encouraging twitter post about learning Java. Base your writing on the given outline."
93+
]
94+
}
95+
],
96+
"supportsAuthenticatedExtendedCard": false,
97+
"additionalInterfaces": [
98+
{
99+
"transport": "JSONRPC",
100+
"url": "http://localhost:10002"
101+
}
102+
],
103+
"preferredTransport": "JSONRPC",
104+
"protocolVersion": "0.3.0"
105+
}
106+
----
107+
108+
[NOTE]
109+
====
110+
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.
111+
====
112+
113+
The description and skills specified in the agent card for the `Content Writer` agent allow the `Host` agent's LLM to determine that the writing sub-task should be sent to the `Content Writer` agent.
114+
115+
==== Agent Communication
116+
117+
The `Host` agent communicates with each A2A server agent using an A2A client. Notice that an A2A client
118+
does not need to be written in the same programming language as an A2A server since all that matters is
119+
that both are using the A2A protocol to communicate with each other.
120+
121+
Later on in this post, we'll see how we can easily swap out the TypeScript `Content Editor` agent for
122+
an equivalent agent written in Java, highlighting the flexibility and interoperability that's made
123+
possible by the A2A protocol.
124+
125+
=== Running the Agents
126+
127+
Let's get this multi-agent system running locally.
128+
129+
==== Content Planner
130+
131+
In a terminal:
132+
133+
[source,shell]
134+
----
135+
cd samples/python/agents/content_planner
136+
----
137+
138+
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.
139+
140+
==== Content Writer
141+
142+
In a terminal:
143+
144+
[source,shell]
145+
----
146+
cd samples/java/agents/content_writer
147+
----
148+
149+
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.
150+
151+
==== Content Editor
152+
153+
In a terminal:
154+
155+
[source,shell]
156+
----
157+
cd samples/js/src/agents/content-editor
158+
----
159+
160+
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.
161+
162+
==== Host
163+
164+
In a terminal:
165+
166+
[source,shell]
167+
----
168+
cd samples/python/hosts/content_creation
169+
uv run .
170+
----
171+
172+
[NOTE]
173+
====
174+
As mentioned in the agent `README.md` files, don't forget to create a `.env` file for each agent with your
175+
`GOOGLE_API_KEY`. This is needed since the agents in this sample make use of Gemini. You can create a
176+
Google AI Studio API Key for free https://aistudio.google.com/[here].
177+
====
178+
179+
=== Access the Content Creation Application
180+
181+
Now that all of our agents are up and running, from your browser, navigate to http://localhost:8083.
182+
183+
Try asking questions like:
184+
185+
* Create a short, concise LinkedIn post about getting started with the Agent2Agent protocol
186+
* Create a short, upbeat X post about Quarkus LangChain4j
187+
188+
image::UI.png[scaledwidth=100%]
189+
190+
=== Swap Out an Agent
191+
192+
One of the most powerful features of the A2A protocol is its interoperability. Let's see this in
193+
action by swapping out the TypeScript-based `Content Editor` agent for an equivalent agent written
194+
in Java.
195+
196+
image::ContentCreationSwapped.png[scaledwidth=100%]
197+
198+
==== Stop the TypeScript Content Editor Agent and Host Agent
199+
200+
First, stop the `Host` agent and the `Content Editor` agent so we can swap out the `Content Editor` agent for
201+
an equivalent agent.
202+
203+
==== Start the Java Content Editor Agent
204+
205+
In a terminal:
206+
207+
[source,java]
208+
----
209+
cd samples/java/agents/content_editor
210+
----
211+
212+
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.
213+
214+
==== Start the Host Agent
215+
216+
In a terminal:
217+
218+
[source,shell]
219+
----
220+
cd samples/python/hosts/content_creation
221+
uv run .
222+
----
223+
224+
==== Access the Content Creation Application
225+
226+
From your browser, navigate to http://localhost:8083 and try asking some questions.
227+
228+
This time, the `Host` agent will seamlessly use the Java-based `Content Editor` agent for editing
229+
content instead of the TypeScript-based `Content Editor` agent. This flexibility is made possible
230+
because the A2A protocol is language-agnostic. This can be really useful for prototyping agents
231+
in one language to get things up and running quickly and then migrating to another language for
232+
a production environment.
233+
234+
== Conclusion
235+
236+
In this post, we saw how to use the A2A protocol to enable agents written in different programming
237+
languages and with different LLM frameworks to collaborate seamlessly to accomplish a goal. We also
238+
saw how easy it is to swap out one of the agents for an equivalent agent written in a different language.
239+
240+
=== Further Reading
241+
242+
* https://github.com/a2aproject/a2a-samples/blob/main/samples/python/hosts/content_creation/README.md[Content Creation Sample]
243+
* https://quarkus.io/blog/quarkus-a2a-java-0-3-0-alpha-release/[Getting Started with Quarkus and A2A Java SDK 0.3.0]
244+
* https://github.com/a2aproject/a2a-samples/tree/main/samples/java/agents[A2A Java SDK Samples]
245+
* https://github.com/a2aproject/a2a-java/blob/main/README.md[A2A Java SDK Documentation]
246+
* https://a2a-protocol.org/latest/specification/[A2A Specification]
247+
248+
136 KB
Loading
140 KB
Loading
136 KB
Loading

0 commit comments

Comments
 (0)