localmTUTS
FollowFollowSubscribe
💻Video + Code Examples·10 mins

Wrapping Agents as A2A Servers

Transform the standalone QAAgent into a fully A2A-compliant server using AgentExecutor, Agent Card, and A2AStarletteApplication.

Wrapping Agents as A2A Servers · 10 mins
Instructor:Welcome back to LocalM Tuts. I am Nilay Parikh. This is lesson 6 of 16, Wrapping Agents as an A2A Server. In the last lesson we built our first A2A agent, a QA Agent powered by GitHub Phi-4. If you are watching this as a standalone video, please find the complete course playlist in below description and follow along with the URL for a course home along with the URL for a course home page. It is also available in the description below. Here is where you find all the code for the lesson. The examples and
Instructor:the link for the GitHub repository is in our description as well as the interactive lesson and the link also available in our description. Clone the repo, open the lesson folder and just simply follow along. Three pieces: an Agent Card JSON at the well-known path. An AgentExecutor that bridges our agent to the A2A protocol and a Starlette server that speaks JSON-RPC and serves the SSE streams. The key concept is the central abstraction. Every framework in this course implements it differently,
Instructor:but the interface always remains the same. Receive a request context, produce events on a queue. Let's see this in action. We will start the A2A server and then we will we will send the JSON-RPC request and watch and verify the agent card. After that we will send the JSON-RPC request and watch the agent respond. Follow along, pause the video if you need to catch up. Hello, welcome to the practical session. We have also created a simple notebook for interactive session and if you haven't got access to VS Code and
Instructor:if you are on the phone or anywhere else, you can certainly use our website which has an interactive notebook. Available with lot of other information and more material. It will help you to build a good learning experience with some decent question and answers that would help you if you are preparing for your interviews. But let us see this live in our notebook session. So let us restart the kernel so everything is good enough. And. In the lesson 6 Wrapping agents as an A2A server, all we are gonna do is
Instructor:implement AgentExecutor and wrap up the component that we built in the fifth lesson, which was an agent. It will handle the multi turn conversation conversations, return artifacts, support task cancellation. If we provide a rich Agent Card image, the streaming events and wire up the default request handler and the Starlette application for server exposure, it will cover most of the A2A protocol features, so this is quite interesting from learning perspective. It's a simple implementation
Instructor:of a single agent, but it covers most of the concept that you would like to learn through the A to A implementation. The first couple of first cells will install all the dependencies if you need and then configuration to the models so let's quickly run them. We already got those dependencies sorted so it should be OK. There you go, we just finished it. We got it there now defining the agent class, which I think we already got there in in a previous configuration. So all we need to do is let's quickly come
Instructor:back to it. So it got same classes, multi- agent, and everything that we did in the previous implementation, so let's run the 3rd. And that's it. Implementation of Enhanced Agent Executor. I would strongly recommend reading this sequence flow. It will help you to understand what exactly this particular example is doing in detail. I will leave it to you for a detailed reading. On. On your available time, but let's now start implementing the Agent executor. AgentExecutor is a wrapper on
Instructor:top of the agent and it is using the A2A component. A2A classes and methods to implement the interface into our agent. So let's run it. So as you can see it using artifacts, data parts, message events, and request context so it's well documented. So it should be OK for anyone to read and understand, but if it is not, please feel free to drop comments and I will try my best to come back. Now we are defining the rich Agent Card. The Agent Card is nothing but just a metadata and an important aspect of this
Instructor:Agent Card is, remember the served card will be exposed by exposed to agents and agents will assess whether they would like to use the skills or capabilities available based on this agent card. So, so its better to always give a good attention that what kind of a density and what kind of a sparsity we want to provide intent. So when LMS are deciding which agent we need to wrap buyer up, which agent we need to connect to, it provide intent. So when LLMs are deciding which agent we need to wire up,
Instructor:chain the path, but to actually let agent discover the capability across the agent in AI and make it organically discoverable. That's the ultimate idea. And that that is a very powerful concept increment. So always make sure that. You spend good time with this agent card because Dad is going to be a very basic building block in terms of how your ecosystem or how your overall architecture of Atki is coming up. Now let's bring up the server is a pretty straightforward which is put the
Instructor:agent executed inside at a provide the memory task too. They are not gonna go in detail especially the memory that is very much agent concept. But in some other tutorial I will making future when I will cover agent in detail, I will discuss the agent take memory in depth in land. Its a very important its very important concept and. One of the one of the lower area where I see very liked likelihood of missing the nuances. So see let's solve this, mark this area and if you know already, you can always.
Instructor:Progression up your knowledge, but please feel free to subscribe and when we got that course up and running you will get a notification. Running the server. So we got all things up and running. Now we just couldn't do is can I run this server is up and running now the server is this thing on. One O1. Bought and what we do is we will, uh, so these are the already something I have already called and this is what the outcome going to look like. But will free it will cover practically every
Instructor:important aspect of it with protocol other than security and other aspect which I said we are gonna touch up, we're gonna touch touch base them just for awareness in this particular tutorial set of tutorial. But in the in the advanced tutorial, we will deep dive into many other. Enterprise related aspects as well, but that tutorial will come in future as well as so again please make sure you subscribe so you get it modification and in the next particular lesson we will use this server to connect
Instructor:with our east to a client and we will see how it works. Yoku agent is now live at 2:00 server. Any A2A client from any framework can discover it at the well known URL and send the task. Next we will build the client. Thanks for watching this lesson on LocalM Tuts. In the next lesson, we build the client side. Discovering agents, sending tasks, and handling both blocking and streaming responses the A2A Protocol course playlist. The link is in the description. See you there in is the description and see you there in
Instructor:the next.

Setup Instructions

0/3

Clone the repository

Clone the course repository to your local machine to follow along with the code examples.

bash
git clone https://github.com/nilayparikh/tuts-agentic-ai-examples/tree/main/a2a/lessons/06-a2a-server
cd $(basename https://github.com/nilayparikh/tuts-agentic-ai-examples/tree/main/a2a/lessons/06-a2a-server)

Create a virtual environment

Create an isolated Python environment for the project dependencies.

bash
python -m venv .venv
source .venv/bin/activate  # or .venv\Scripts\activate on Windows

Install dependencies

Install all required packages from the requirements file.

bash
pip install -r requirements.txt
nilayparikh/tuts-agentic-ai-examples/tree/main/a2a/lessons/06-a2a-serverGitHub

Complete source code for this lesson.

github.com/nilayparikh/tuts-agentic-ai-examples/tree/main/a2a/lessons/06-a2a-server
Q&A

Q & A

Q

What is the difference between AgentExecutor and the QAAgent?

QAAgent contains your business logic. AgentExecutor is the A2A protocol adapter — it receives requests, extracts the user message, calls your agent, and formats the response as A2A events.

Q

Why use InMemoryTaskStore instead of a database?

InMemoryTaskStore is sufficient for development. For production, the A2A SDK supports PostgreSQL, MySQL, and SQLite via the sql extras.

Q

What does the Agent Card's skills field do?

Skills tell clients what the agent can do. An orchestrator inspects skills to decide which agent should handle a task.

Q

Can I have multiple skills on one agent?

Yes. An agent can declare multiple skills. The client or orchestrator decides which to invoke based on the task.