Add A2A consuming quickstart for Kotlin - #2118
Conversation
adk-kotlin has been able to consume remote A2A agents since 0.6.0, and the docs had no Kotlin page for it. This adds one alongside the Python, Go and Java quickstarts, plus its nav entry. A new page rather than a tab: docs/a2a has no tab groups at all, it is one page per language, so this follows the section's own shape. Two dependencies are needed, not one. The a2a artifact publishes the A2A SDK as runtime-only, and A2AAgent's httpClient parameter defaults to JdkA2AHttpClient(), so a2a-java-sdk-client has to be on the compile classpath as well. That number was established by compiling, not by reading module metadata: the a2a artifact alone fails with "Cannot access class 'A2AHttpClient'", and adding the client artifact is sufficient -- spec and the jsonrpc transport arrive transitively. Only the consuming side is documented, because that is all that exists: no webserver source at v0.7.0 mentions a2a, so there is no Kotlin equivalent of the exposing quickstarts. The page says so and links to the Python and Java ones. A2AAgent is a suspending factory, and the implementation class behind it is internal, so the factory is the only way to construct one. The snippet notes it. Verified end to end rather than by compiling alone: served a real agent card from a local server and ran the snippet, which fetched it, parsed it and wired the remote agent in as a sub-agent -- "Root agent root_agent delegates to prime_agent".
✅ Deploy Preview for adk-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
||
| ## Connect to the remote agent | ||
|
|
||
| `A2AAgent` fetches that card and reads the remote agent's name, description and |
There was a problem hiding this comment.
Technically we dont fetch the name, the name is given by the user as an argument to A2AAgent, so maybe just A2AAgent fetches that card from the URL and reads the remote agent's description from it. or sth similar. To be changed here and in the code comment.
| model = Gemini(name = "gemini-flash-latest"), | ||
| instruction = | ||
| Instruction( | ||
| "Roll dice yourself, and delegate prime checks to prime_agent.", |
There was a problem hiding this comment.
Nit: root_agent has no dice-rolling tool, so "Roll dice yourself" points at nothing. prime_agent is the only sub-agent here, so the instruction should cover just the prime delegation, matching the Java snippet's "You are a helpful assistant that can check prime numbers by delegating to prime_agent." (A2aConsumerSnippet.java:49)
…ming # Conflicts: # tools/kotlin-snippets/files_to_test.txt
A2AAgent does not read the remote's name from the card: the name is the caller's, and independent of what the card advertises. It does not read the transport either, which is hardcoded to JSON-RPC. What the card supplies is the description and the streaming capability. The server step told readers to start a server without saying how, and the two obvious candidates do not work: adk-kotlin parses A2A 1.0 cards, which require supportedInterfaces with a protocolBinding, and the adk-java and adk-python samples both publish 0.3-style cards that A2AAgent rejects with AgentCardResolutionError. State that, and give a minimal card verified by running the snippet against it. Also fix the root agent instruction, which referenced dice-rolling the agent cannot do; match the Java snippet's prime-delegation wording.
|
Both fixed, thanks. On the card: you're right the name is ours, and the transport claim was wrong too — it's hardcoded to JSON-RPC. The card only supplies the description and streaming capability. Updated the page and the code comment. Instruction now matches the Java snippet's prime-delegation wording. |
Summary
adk-kotlin has been able to consume remote A2A agents since 0.6.0, and the
docs had no Kotlin page for it. This adds
docs/a2a/quickstart-consuming-kotlin.mdalongside the Python, Go and Java quickstarts, with its nav entry, a transcluded
snippet, and the two dependencies it needs.
A new page, not a tab
docs/a2a/has zero tab groups — it is one page per language(
quickstart-consuming{,-go,-java}.md). So a Kotlin page follows the section'sown shape rather than breaking a pattern.
The dependency set: two, not one — established by compiling
The a2a artifact alone is not enough. It publishes the A2A SDK as
runtime-only (
jvmApiElements-publishedexposes onlykotlin-stdlib), whileA2AAgent'shttpClientparameter defaults toJdkA2AHttpClient()— so thetype must resolve at compile time:
Adding
a2a-java-sdk-clientfixes it, and nothing further is required —specand the JSON-RPC transport arrive transitively. I verified that by building, not
by reading module metadata, and it contradicts an earlier estimate of four
artifacts.
Notes for reviewers
webserver/**source atv0.7.0 mentions a2a, so there is no Kotlin equivalent of the exposing
quickstarts. The page states this and links to the Python and Java ones rather
than leaving a dead end.
A2AAgentis a suspending factory, andA2AAgentImplisinternal, so thefactory is the only way to build one. There's also a non-suspending overload
taking an
AgentCarddirectly, which the page mentions.Kotlin, notKotlin v0.6.0), matching every otherpage in this section — and avoiding a contradiction with the
0.7.0dependencythe page tells you to add.
Verification
Not just compiled — run end to end. I served a real agent card from a local
server at the well-known path and executed the snippet:
So the factory fetched the card, parsed it, and the remote agent was accepted as
a sub-agent.
verify_snippets.pypasses all six levels.