A2A Client
Connect to AgentVisor's A2A (Agent-to-Agent) transport from an external client — curl scripts and a Python client for Agent Card discovery, task creation, and streaming.
Difficulty: Intermediate
This is a client, not an agent — it demonstrates calling an already-running AgentVisor instance from outside the sandbox. Pair it with any agent that has A2A transport enabled.
What This Demonstrates
- Agent Card discovery: Fetching
/.well-known/agent-card.jsonto find available skills - Task management: Creating, polling, and canceling tasks over JSON-RPC 2.0
- Conversation continuity: Using
contextIdto continue a conversation across messages - Streaming: Receiving incremental updates via SSE
Prerequisites
Start an agent with A2A transport enabled:
agentvisor template create langgraph/chatbot-agent
cd chatbot-agent
docker compose up -d
AGENTVISOR_API_A2A_ENABLED=true agentvisor serve .
Verify the Agent Card is being served:
curl -s http://localhost:8090/.well-known/agent-card.json | jq .
Setup
In a separate directory:
agentvisor template create clients/a2a-client
cd a2a-client
Quick Start with curl
# Run the full walkthrough: discovery, send message, poll status, list tasks,
# follow-up message, blocking mode, streaming request, cancel, error handling
./curl-examples.sh
# Or against a non-default host
BASE_URL=http://agentvisor:8090 ./curl-examples.sh
Python Client
cd python-client
pip install -r requirements.txt
Discover agents:
python discover.py
python discover.py --json
python discover.py --url http://agentvisor:8090
Send messages and manage tasks:
# Send a single message
python invoke.py --skill chatbot --message "What is the capital of France?"
# Interactive chat session
python invoke.py --skill chatbot --interactive
# Continue a conversation
python invoke.py --skill chatbot --message "What about Germany?" --context-id <context-id>
# List tasks for a context
python invoke.py --list-tasks --context-id <context-id>
# Get or cancel a specific task
python invoke.py --get-task <task-id>
python invoke.py --cancel-task <task-id>
# Block until the task completes
python invoke.py --skill chatbot --message "Hello" --blocking
Streaming:
python stream.py --skill chatbot --message "Tell me a story"
python stream.py --skill chatbot --message "Continue" --context-id <context-id>
Files
a2a-client/
├── curl-examples.sh # Self-contained curl walkthrough of the A2A JSON-RPC API
└── python-client/
├── requirements.txt
├── discover.py # Agent Card discovery
├── invoke.py # Task creation and management
└── stream.py # Streaming task updates
See Also
- A2A Transport Guide — enabling the transport and the full JSON-RPC method reference
- A2A Gateway — the inverse pattern: your agent calling external A2A agents
- MCP Client — the same idea over the MCP transport
- Chatbot Agent — a simple agent to test against