This example shows how the trpc-agent-go A2A client talks to an ADK Python A2A server.
Two example cases are provided:
| Case | Server | Client | Features |
|---|---|---|---|
| Tool Call | adk/adk_server.py (port 8081) |
trpc_agent/main.go |
Streaming + tools (calculator, current_time) |
| Code Execution | adk/adk_codeexec_server.py (port 8082) |
trpc_agent_codeexec/main.go |
Streaming + Python code execution |
examples/a2aadk/
├── README.md # This guide
├── trpc_agent/
│ └── main.go # Go client for tool call example
├── trpc_agent_codeexec/
│ └── main.go # Go client for code execution example
└── adk/
├── adk_server.py # ADK server with tools
└── adk_codeexec_server.py # ADK server with code execution
| Component | Version | Notes |
|---|---|---|
| Go | 1.21+ | Needed for trpc_agent/main.go |
| Python | 3.10+ (3.11 recommended) | Required by the ADK server |
| Pip deps | See adk/requirements.txt |
Install via pip install -r requirements.txt |
| API key | OPENAI_API_KEY |
Example server defaults to OpenAI-compatible models |
- (Optional) Create a virtualenv:
cd trpc-agent-go/examples/a2aadk/adk python3 -m venv venv source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Configure model access:
export OPENAI_API_KEY="<your-openai-key>" # Optional overrides export MODEL_NAME="gpt-4o-mini" export OPENAI_API_URL="https://your-endpoint/v1"
cd trpc-agent-go/examples/a2aadk/adk
python3 adk_server.pycd trpc-agent-go
go run ./examples/a2aadk/trpc_agent --url http://localhost:8081Server highlights:
- Streaming responses plus two example tools:
calculatorandcurrent_time. logging_request_converterprintsuser_id/session_idfor debugging.
cd trpc-agent-go/examples/a2aadk/adk
python3 adk_codeexec_server.pycd trpc-agent-go
go run ./examples/a2aadk/trpc_agent_codeexec --url http://localhost:8082Server highlights:
- ADK agent with
PythonCodeExecutionenabled. - LLM can generate and execute Python code, returning results via A2A protocol.
Client behavior:
- Displays code execution events (
💻 Code Execution) and results (📊 Execution Result) separately. - Uses MessageID-based deduplication to handle ADK's repeated event delivery.
| Scenario | Details |
|---|---|
| Cumulative streaming | ADK A2A events send "full content so far" in every delta. The client captures the last valid intermediate event rather than reading deltas incrementally. |
| Final event duplication | ADK may send a malformed final event that duplicates content. The client ignores the final event payload. |
| Code execution event duplication | ADK may send repeated code execution events with the same MessageID. The client uses MessageID-based deduplication. |
| User propagation | a2aagent places Session.UserID into the X-User-ID header. Override via a2aagent.WithUserIDHeader(...). |
- "OPENAI_API_KEY not set" warning: the server cannot call OpenAI without the env var. Run
export OPENAI_API_KEY=...before startingadk_server.py. - Go client cannot connect: ensure the ADK server is listening on the
--urlyou pass (defaulthttp://localhost:8081). Adjust either the server port or the flag. - Need to disable ADK compatibility? This example assumes an ADK peer, so trpc-agent-go keeps the
adk_metadata prefix enabled. If you target a non-ADK service you can calla2a.WithADKCompatibility(false)in your own server, but no change is required here.
After completing the steps above, the Go client and ADK server will interoperate and you can observe tool invocations plus final answers directly in the terminal. Happy debugging!