Instructor:Welcome back to LocalM Tuts. I am Nilay Parikh. This is lesson 7 of the 16 A2A Client Fundamentals. Last time we wrapped up our agent as a fully discoverable A2A server with Agent Card and HTTP endpoints. If you are watching this as a standalone video, please find the link of the full playlist in the description section below. Here is what you gonna find the code for this lesson, the GitHub repository and interactive course page in the description section. Clone the repo, open the lesson folder and follow along.
Instructor:The client has 3 important steps. Resolve the Agent Card to discover the capabilities. Send the blocking request to get the full response and send the streaming request for the real-time SSE updates. Blocking is a simple one request, one response. Streaming gives you real-time progress, status updates as the agent works and the artifacts as they are generated. Both use the same JSON-RPC protocol. Let's see this in action. First, make sure the A2A server from lesson 6 is running on port 10001 and then we
Instructor:will run the client script. It discovers the Agent Card, sends the blocking request, receives the response, and then does the same with streaming. Watch SSE event flow in real time. We will have the server running from our last example server and it is listening on 10001 so now let's see how it works on a client side. We also have an interactive page if you are not with access to a computer. You can obviously use this on mobile phone. It's screen-friendly and it got a lot of other information to
Instructor:read with the question and answers. Very helpful in the interviews if you are preparing for any. Artificial intelligence engineer roles. Let's let's get started with our client. So this is a simple, notebook. With covering most of the important client fundamentals and in this notebook we will inspect the multiple skills, send the blocking request, handle the multi turn conversation, stream the response with an A2A client, send_message and streaming artifacts with TextPart, DataPart, cap-
Instructor:abilities. We will also try to cancel the task. See what happened, exchange structured data and handle the errors gracefully. You can see what features we are exercising here. There is a there is a decent read in this notebook. I would strongly recommend you to take the time, give it a read for couple of times. It might be difficult concept if you are not familiar with abstract programming. So let's start installing the dependencies if we need to. All dependencies there, just running a simple class which.
Instructor:Prides U did I run this? Umm. At the window, check base URL and then discover the agent. Discover the agent. And remember, from our last skills, policy QA, custom claims filing, and policy summary, it's all coming from server. So we haven't implemented an agent class here nor we have a nor we have implemented an agent server. We are purely connecting. To localhost 10001 and you can see based on agent card we are resolving all of these and we are getting skills and all the information that we need an
Instructor:R alms to decide what skills it need and LLMs to decide what skills they need see if you are ready with helper. Very good client is ready. Now we just going to build a very simple request. So these are just the builder build-up methods. Let's define them here. I think there methods, let's define them and then we will start with the blocking call. It's a simple policy query. So in this particular example it is running via the server. So if I open the server here you can see the are
Instructor:connecting. So we connected the agent card first and now we are connecting to the HTTP request which is the JSON- RPC request coming from this client. Well done. So we I think completed the bill request. We just completed the block task completed answer. So what we have asked what is the annual deductible? So we got all the same answers from the client. So if you have seen the lesson 5, this was the same answer coming and now we are getting the same agent. Executed using the server and this is the This
Instructor:is the beauty. We can actually compare all the answer, question and answer from agent and client. They will always match and now we are going to do the test multiple question and answer. Very good, its moving quickly. Wonderful we got all the answers and their absolutely correct now multi term conversation. It's the same monthly term conversation that we have demonstrated in the right way agent, but now you would be calling using the A2A protocol. We have the server method?
Instructor:So let's. Turn the partial claim and we will send missing information so it should come back with the state input required. And then we will provide the missing details. So it has come back and said task input required state. Please provide the rate of service amount in description. So I am going to provide them here. Service on this and description and by the way I am not passing the structure data I am passing. Semantical data and it will translate into structured data and process.
Instructor:This is why. Self discoverable agent with a true agent capability of acidity. And This is why it particularly solved the Earth square problem because if let's say if you are building a insurance company claim portal or a claim submission portal. Its one of the nightmare to handle the number of the fields that required number of the process is that required and all of these can actually become very simple if the correct abstract process has been followed and we actually build the agent
Instructor:Akai and that reduce the north square problem. Into the end problem and O square is exponential cost against the linear business value compared to O which is the linear cost against the linear business value and that's why when the business scale the O always give far more competitive edge over the O square. So well we completed the task, the claim process has been completed and also of staff that require expected is coming back and it explain what multi multi full summary should look like structure data
Instructor:policy. So we are going to pass simple information and say give me summary of my policy and this is the same example. We also run during the 82 agent. There you go, it's perfect. Streaming response same way. Please read the. The sequence diagram its very interesting and important understand how the SSE stream works. JSON-RPC is not deal, they are not dealing with SSE when it comes to back end up simple micro service architecture or service oriented architecture. But SSEs are very important when it comes to agent
Instructor:Agri and something need to be mastered for sure. So what I'm going to do is I'm gonna stream my question and answer. And see look it is going to it is actually working in progress and soon as my question and answer is been delivered back from agent to to this particular client it will print it. So its continuously running instead of blocking the all it is progressing. As it receive the artifacts and the process and updates. There we hope we could. Both of them very good. Now we are doing the stream
Instructor:policy summary. It's going to work like same so I'm gonna skip it. But this is how the response going to look like the Tau scanlation. So we will fire the task at the end will cancel it. There we go, we find the task. First of all, we got the response, then we cancel it. So if you see here we build a payload, we create a request, I want to file medical claims and and then immediately we send the cancellation request cancellation as well. So here cancel payload and then. And we got this whole ideas.
Instructor:Then tax everything. They will discuss return task polling. So it will constantly give us what is happening with the task. There is nothing there and error handling. So here we expect. The error. Which is. Not the error that is. UM, not the error, technical error, but as I said that there will be out of the scope questions like what medical, medical, what medication are excluded that that that information doesn't available, is not available in the context. So we anticipate that policy document is
Instructor:not explicitly. Specific the requirement so this is what it call safe queries and guard drilling and let's see how it works. So air handling. And obviously we do handle errors such as like, connection etcetera. So policy does not specifically, however, it does not. Perfect. That the non existence task. So here you can see they are trying to get some of the task that doesn't exist. We haven't created and we are getting the response graceful fail test, the invalid method. This method doesn't
Instructor:exist and we get a very reasonable massage and the experiment. So we are going to file the spawns. Here we go. You are filling the response and response has been filed and now we want to close the client. So lets close the client and there we go. And we covered everything that we anticipated. So let's see how server works. So you can see here we made lot of good request to server and we practically achieve everything that we need and including the request failure. That we force the method of form.
Instructor:So that's a very. Detail understanding of Janvi capabilities, what an A2A client can do. So this time we went from client to server and then we invoke the agent via the executor. So abstract executor and. And that proves how a 2 evening actually deliver end to end agent infrastructure and how it communicate across the multiple layer. Now you have the complete server client loop, agent caught discovery, blocking requests, streaming request error handling. The client
Instructor:pattern is reusable in every integration session. Thanks for watching this lesson on local LocalM Tuts. In the next session we will integrate Microsoft Agent Framework. So from next lessons we will start exploring different frameworks available to us and how they integrate with their A2A agents. Building an orchestrator. That root the task to remote A2A agents and you can find the next video in the A2A protocol course playlist link available in the description ICU there.
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/07-a2a-client
cd $(basename https://github.com/nilayparikh/tuts-agentic-ai-examples/tree/main/a2a/lessons/07-a2a-client)
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.
What is the difference between blocking and streaming modes?
Blocking (SendMessage) waits for the complete response before returning. Streaming (SendStreamingMessage) returns an async iterator of SSE events — you get status updates and artifact chunks in real time.
Q
Why does the message use 'kind' instead of 'type' for parts?
The A2A SDK uses 'kind' as the discriminator field for message parts to avoid conflicts with Python's built-in 'type' and follows the Pydantic discriminated union pattern.
Q
Can this client call agents built with different frameworks?
Yes. The A2A protocol is the standard. This client sends JSON-RPC over HTTP — it works against any server that serves an Agent Card and accepts A2A messages.
Q
What happens if I reuse a task ID?
Reusing a task ID continues the same conversation. The server appends the new message to the existing task history, enabling multi-turn interactions.