You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Streaming responses plus two example tools: `calculator` and `current_time`.
59
+
-`logging_request_converter` wraps `convert_a2a_request_to_agent_run_request` so each request prints `user_id` / `session_id` for debugging.
60
+
- You can plug custom `request_converter` / auth modules into `A2aAgentExecutorConfig` to read `X-User-ID` headers and populate ADK sessions.
61
+
62
+
## Run the Go A2A client
63
+
64
+
```bash
65
+
cd trpc-agent-go
66
+
go run ./examples/a2aadk/trpc_agent --url http://localhost:8081
67
+
```
68
+
69
+
Client behavior:
70
+
71
+
1. Sends three prompts in order (two normal chats plus one tool-using prompt).
72
+
2. Streams tool-call/tool-response logs in real time but prints the assistant answer only once at the end.
73
+
3. Automatically forwards local `userID` / `sessionID` through the `X-User-ID` HTTP header.
74
+
4. Works around ADK's final-event content duplication by capturing content from intermediate events only (see "ADK-specific notes" below).
75
+
76
+
## ADK-specific notes
77
+
78
+
| Scenario | Details |
79
+
| -------- | ------- |
80
+
| No incremental text | ADK A2A events send "full content so far" in every delta (cumulative streaming). The client captures the last valid intermediate event rather than reading deltas incrementally. |
81
+
| Final event duplication bug |**Important**: ADK's current A2A implementation may send a malformed final event that duplicates content or prepends the user's question. The client works around this by only capturing content from non-final events and ignoring the final event payload. |
82
+
| User propagation |`a2aagent` places `Session.UserID` into the `X-User-ID` header. Override via `a2aagent.WithUserIDHeader(...)` if another header is needed. |
83
+
| Reading user ID in ADK | Enable A2A auth/request converter components to extract the header or `AgentRunRequest.user_id` and store it in the session context. `logging_request_converter` in this example is a reference implementation; production setups can inject their own logic via `A2aAgentExecutorConfig`. |
84
+
| Session diagnostics | Expect logs like `📋 Session Info - User: xxx, Session: xxx`. They confirm that the header propagated correctly without extra wiring. |
85
+
86
+
## FAQ
87
+
88
+
1.**"OPENAI_API_KEY not set" warning**: the server cannot call OpenAI without the env var. Run `export OPENAI_API_KEY=...` before starting `adk_server.py`.
89
+
2.**Go client cannot connect**: ensure the ADK server is listening on the `--url` you pass (default `http://localhost:8081`). Adjust either the server port or the flag.
90
+
3.**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 call `a2a.WithADKCompatibility(false)` in your own server, but no change is required here.
91
+
92
+
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!
0 commit comments