🚀JSON-RPC Methods in Agent-to-Agent (A2A) Protocol | Task Send, Get, Subscribe, Push Notifications
By Tech Wisdom
Summary
## Key takeaways - **JSON-RPC in A2A: HTTP & JSON**: JSON-RPC methods in A2A protocols are typically invoked via HTTP POST requests, with both request and response bodies adhering to JSON-RPC formats or utilizing server-sent event streams for communication. [00:27], [00:43] - **Task Send: Immediate or Polling Tasks**: The `task/send` method initiates or continues a task, suitable for immediately completing or synchronous tasks, and can also support continuously polling-based workflows. [00:46], [00:59] - **Task Subscribe: Long-Running & Streaming**: For long-running or streaming tasks, `task/subscribe` starts the task and subscribes to updates using a long connection, provided the remote agent supports streaming capabilities as indicated in its agent card. [01:51], [02:01] - **Task Get: Status and Artifact Retrieval**: The `task/get` method is used to periodically poll for task status or retrieve the final task results and artifacts after a task has been sent, similar in usage to `task/send`. [03:02], [03:15] - **Push Notifications: Managing Agent Alerts**: Push notification methods (`push_notification/set` and `push_notification/get`) allow agents to configure and retrieve settings for receiving status updates, requiring the agent to support this feature as indicated by a flag in its agent card. [04:50], [05:52] - **Task Resubscribe: Re-establishing Streaming Connections**: When a connection for a long-running task is interrupted, `task/resubscribe` allows the client agent to request re-establishment of the streaming response connection. [06:23], [06:38]
Topics Covered
- How to Initiate and Manage Synchronous Tasks?
- Managing Long-Running Tasks with Streaming Subscriptions
- How to Retrieve Task Status and Optional History?
- When and How to Cancel an Ongoing Task?
- Configuring Push Notifications for Real-time Task Updates
Full Transcript
Hi all, welcome back to another
interesting video about A2A protocol.
Today we are going to see the JSON RPC
method used in the A2A
[Music]
[Applause]
[Music]
[Applause]
[Music]
protocol. So first let's see what is an
overview of this RPC methods. So all RPC
methods are invoked by HTTP and usually
in the post method and all the request
and response body must be in the format
of JSON RPC request or JSON RPC response
or it should be a server send event
stream. The first method we are going to
see is task send. And this method is
used to send or initiate or continue a
task from a local client to remote
client. And it's suitable for
immediately completing task or a
synchronous task or continuously polling
based for workflows uh implementation.
And this particular task send method is
using a one particular object is called
task send parameters. And this object
contains the input message and also
different parameters for the task
execution which is basically the
instruction to the remote client. And it
usually returns the current state or a
final stage of the task with the
artifacts which is the
response. And this is a sample uh JSON
schema for sending this method. The
method name is task send as you can see
here. And we pass the task ID. The task
id is generated by the client or local
agent and then whatever be the
instruction we need to send to the
remote client. The second method we are
discussing is send subscribe and it is
used for long running or streaming task
and it is only possible to send if the
agent the remote agent is supporting
this streaming capability which you can
find in the agent card
schema and it start the task. So this
method do two actions. One, it will
start the task then it will subscribe to
the updates and we can do this using a
long connection which implemented using
servers and
events and it is also using a special
object called send task streaming
response and here is a sample one. So
the name of the method and the id of the
task then the
inputs and the next schema is containing
uh the response given by each stream or
each uh stage of the streaming task
whether the state is in progress or it's
completed. when the state when
particular long-running task is
completed this state will move to
completed and then we will get the
result of that particular
response. The next method we are going
to discuss is get and this is used in to
get periodically the polling task or to
get the final task after the task is
sent after some time and it retrieves
the status artifacts and optional
history. This is also used similar to
task send. This method also use task
query
parameters and we can see the schema is
same as uh task send. So the method is
task get and the task unique identifier
and then the response will be a message
and artifact uh from the remote agent.
The history is not relevant at this
point but this is used to how long the
history needs to be maintained for this
particular task and how long the history
uh response needs to be included in the
response uh method as well. When we go
for the implementation of agent we will
uh go through this uh with the
scenarios. The next task we will be
discussing is task cancel. As the name
implies, it's used to request a
cancellation of ongoing request or task.
Um in particular scenarios maybe the
client agent decides that it it it do
not want to go for a task execution most
probably in the streaming task then it
can use this method and the response
will be the update of the task uh like
it is canled or the response is uh
successful like that and it is also use
the task query parameters and one of the
sample would be like this which will
pass in the parameter object as the task
identifier. This is usually usually a
GUID a unique identifier. For the method
purpose only we are using this just a
number. Now the next method is for the
notification push
notification and this is mainly used to
update or set the notification
configuration and it used to set the
configuration and after that then we can
the server can send the status updates
the response update to the client
objects and it streams the send task
streaming response and this also needs
to the server needs to support this
notification feature which we can find
in the agent card with a flag called
push notification is equal to true in
the capability section of the agent card
and this is the sample response task
push notification set and it will the
configuration for one particular task is
this and the endpoint is this. This
means once the server want to send some
updates, the server send the
notification to this particular URL and
from this particular uh implementation
URL, the client agent read the
notification. Now the put notification
get. So this method is used to retrieve
the configuration of the push
notification that is also used the task
ID and as it we know that the server the
agent server needs to support this
configuration which can be identified in
the agent card as push notification
equal to true and once again as sample
schema the task push notification get
and the parameters we will pass this
task identification for particular
notification.
Then task resubscribe. This is linked to
the long running or streaming task. So
we see that the long running task you
usually use server send events but it's
a connection can be disconnected. In
that scenarios the client again request
the streaming response by using the
resubscribe. then the SSC connection
will be reestablished and then the
response will be sent to uh the client
from the remote agent. So the as it we
know that it is also require the server
to support streaming and we can read
this property in the agent card and once
again the sample schema the task and
resubscribe that's the method name and
it will pass the task ID information
then the current status of the streaming
response will be sent back to the client
agent. So we have discussed uh the
important methods JSON RPC methods
today.
Loading video analysis...