Chat: serve a messages-style task as an A2A endpoint, so any A2A client — including another LLM using it as a tool — can hold a conversation with your environment.
Chat is protocol-agnostic (see Chat); the A2A layer is a reference server kept outside the SDK on purpose. Copy and adapt it from cookbooks/a2a-chat.
The pieces
| File | What it does |
|---|---|
server.py | A2A server: one Chat (conversation) per A2A context, agent card, citations artifact |
client.py | Minimal A2A client: send messages, print replies |
llm_client.py | LLM-fronted client: an OpenAI model decides when to call the A2A agent as a tool |
chat_env.py | Sample chat environment with messages-style tasks to serve |
The environment
A chat-style task takes the running conversation as amessages parameter and yields it as the prompt:
chat_env.py
Run it
Fromcookbooks/a2a-chat (uv resolves the dependencies on first run):
/.well-known/agent-card.json and accepts A2A messages at the root endpoint. Each A2A context gets its own Chat, so concurrent conversations stay independent.
Configuration is via env vars: HUD_MODEL picks the agent’s model (gateway, needs HUD_API_KEY), HUD_TASK/HUD_ENV pick the task row, HUD_SOURCE spawns a different env source, and HUD_ENV_URL attaches each turn to an already-served control channel (e.g. hud serve chat_env.py → HUD_ENV_URL=tcp://127.0.0.1:8765) instead of spawning.