Skip to content

Commit eecbc5a

Browse files
docs: add HTTP/JSON-RPC examples to a2a-agents (#538)
Signed-off-by: Moritz Schmitz von Hülst <mschmitzvonhuelst@gmail.com>
1 parent 5a19119 commit eecbc5a

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

‎docs-site/content/kagent/latest/examples/a2a-agents.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ The following table covers the methods that this example uses. The `TaskPushNoti
5454

5555
{{< reuse "kagent-docs/snippets/grpcurl-prerequisites.md" >}}
5656

57+
The examples in the rest of this page use `grpcurl` to call the gRPC transport. The controller serves the same service over HTTP/JSON-RPC on the same port `8083`; the `Call it over HTTP` section near the end of this page shows the equivalent `curl` calls.
58+
5759
## Read the agent card
5860

5961
An A2A client typically starts by reading the agent card, which tells it what the agent is and which protocol features the agent supports.
@@ -479,6 +481,40 @@ Answering a pause needs the human-in-the-loop extension, which a caller requests
479481
480482
A tool approval works in the same way, but the agent sends `tool_approval_request`, and the caller answers with `tool_approval_response`. For the pause kinds, the approval model, and what a nested agent's pause looks like, see [Human in the loop]({{< link path="agents/human-in-the-loop" >}}).
481483

484+
## Call it over HTTP
485+
486+
The examples so far call the gRPC transport with `grpcurl`. The controller serves the same service over HTTP/JSON-RPC on the same port `8083`, where the URL path selects the Agent instead of a `tenant` field. Both forms below reach the same service the `grpcurl` examples use, with the same `A2A-Version: 1.0` header.
487+
488+
1. Read the Agent's card with the JSON-RPC interface URL.
489+
```bash
490+
curl -s localhost:8083/agents/kagent/my-first-agent/.well-known/agent-card.json
491+
```
492+
493+
The card advertises the JSON-RPC URL first, then the gRPC interface. Point every JSON-RPC call at the first `supportedInterfaces` entry, whose `url` is `http://<controller>/agents/<namespace>/<name>`. A hand-assembled HTTP call sets the Agent in the URL and needs no `tenant`; a `tenant` that an HTTP request does supply must match its URL.
494+
495+
2. Send a message with a JSON-RPC `2.0` request. The body mirrors the `SendMessage` call from [Send a message](#send-a-message): `messageId`, `role`, and at least one `parts` entry. Omitting both a `contextId` and a task ID starts a new Session.
496+
```bash
497+
curl -s -X POST localhost:8083/agents/kagent/my-first-agent \
498+
-H 'Content-Type: application/json' \
499+
-H 'A2A-Version: 1.0' \
500+
-d '{
501+
"jsonrpc": "2.0",
502+
"id": "request-1",
503+
"method": "SendMessage",
504+
"params": {
505+
"message": {
506+
"messageId": "'$(uuidgen)'",
507+
"role": "ROLE_USER",
508+
"parts": [{"text": "What is 7 times 6? Answer with just the number."}]
509+
}
510+
}
511+
}'
512+
```
513+
514+
The reply is the same task the `SendMessage` gRPC call returns: the answer arrives in `artifacts`, and `contextId` is the Session ID to repeat on a follow-up message.
515+
516+
3. The JSON-RPC surface uses the pinned upstream A2A v1 SDK method names: `SendMessage`, `SendStreamingMessage` (streams events over the same `POST` endpoint), `GetTask`, `ListTasks`, `CancelTask`, `SubscribeToTask`, and `GetExtendedAgentCard`. Those are the v1 names for what older A2A clients called `message/send`, `message/stream`, `tasks/get`, `tasks/list`, `tasks/cancel`, and `tasks/resubscribe`.
517+
482518
## Clean up
483519

484520
* This example does not create Kubernetes resources, so you have nothing to delete.

‎docs-site/content/kagent/main/examples/a2a-agents.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ The following table covers the methods that this example uses. The `TaskPushNoti
5454

5555
{{< reuse "kagent-docs/snippets/grpcurl-prerequisites.md" >}}
5656

57+
The examples in the rest of this page use `grpcurl` to call the gRPC transport. The controller serves the same service over HTTP/JSON-RPC on the same port `8083`; the `Call it over HTTP` section near the end of this page shows the equivalent `curl` calls.
58+
5759
## Read the agent card
5860

5961
An A2A client typically starts by reading the agent card, which tells it what the agent is and which protocol features the agent supports.
@@ -479,6 +481,40 @@ Answering a pause needs the human-in-the-loop extension, which a caller requests
479481
480482
A tool approval works in the same way, but the agent sends `tool_approval_request`, and the caller answers with `tool_approval_response`. For the pause kinds, the approval model, and what a nested agent's pause looks like, see [Human in the loop]({{< link path="agents/human-in-the-loop" >}}).
481483

484+
## Call it over HTTP
485+
486+
The examples so far call the gRPC transport with `grpcurl`. The controller serves the same service over HTTP/JSON-RPC on the same port `8083`, where the URL path selects the Agent instead of a `tenant` field. Both forms below reach the same service the `grpcurl` examples use, with the same `A2A-Version: 1.0` header.
487+
488+
1. Read the Agent's card with the JSON-RPC interface URL.
489+
```bash
490+
curl -s localhost:8083/agents/kagent/my-first-agent/.well-known/agent-card.json
491+
```
492+
493+
The card advertises the JSON-RPC URL first, then the gRPC interface. Point every JSON-RPC call at the first `supportedInterfaces` entry, whose `url` is `http://<controller>/agents/<namespace>/<name>`. A hand-assembled HTTP call sets the Agent in the URL and needs no `tenant`; a `tenant` that an HTTP request does supply must match its URL.
494+
495+
2. Send a message with a JSON-RPC `2.0` request. The body mirrors the `SendMessage` call from [Send a message](#send-a-message): `messageId`, `role`, and at least one `parts` entry. Omitting both a `contextId` and a task ID starts a new Session.
496+
```bash
497+
curl -s -X POST localhost:8083/agents/kagent/my-first-agent \
498+
-H 'Content-Type: application/json' \
499+
-H 'A2A-Version: 1.0' \
500+
-d '{
501+
"jsonrpc": "2.0",
502+
"id": "request-1",
503+
"method": "SendMessage",
504+
"params": {
505+
"message": {
506+
"messageId": "'$(uuidgen)'",
507+
"role": "ROLE_USER",
508+
"parts": [{"text": "What is 7 times 6? Answer with just the number."}]
509+
}
510+
}
511+
}'
512+
```
513+
514+
The reply is the same task the `SendMessage` gRPC call returns: the answer arrives in `artifacts`, and `contextId` is the Session ID to repeat on a follow-up message.
515+
516+
3. The JSON-RPC surface uses the pinned upstream A2A v1 SDK method names: `SendMessage`, `SendStreamingMessage` (streams events over the same `POST` endpoint), `GetTask`, `ListTasks`, `CancelTask`, `SubscribeToTask`, and `GetExtendedAgentCard`. Those are the v1 names for what older A2A clients called `message/send`, `message/stream`, `tasks/get`, `tasks/list`, `tasks/cancel`, and `tasks/resubscribe`.
517+
482518
## Clean up
483519

484520
* This example does not create Kubernetes resources, so you have nothing to delete.

0 commit comments

Comments
 (0)