Skip to content

Add A2A consuming quickstart for Kotlin - #2118

Open
happyhuman wants to merge 5 commits into
mainfrom
docs-kotlin-a2a-consuming
Open

Add A2A consuming quickstart for Kotlin#2118
happyhuman wants to merge 5 commits into
mainfrom
docs-kotlin-a2a-consuming

Conversation

@happyhuman

Copy link
Copy Markdown
Collaborator

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.md
alongside 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's
own 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-published exposes only kotlin-stdlib), while
A2AAgent's httpClient parameter defaults to JdkA2AHttpClient() — so the
type must resolve at compile time:

e: Cannot access class 'A2AHttpClient'. Check your module classpath ...

Adding a2a-java-sdk-client fixes it, and nothing further is required — spec
and 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

  • Consuming only, because that's all that exists. No webserver/** source at
    v0.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.
  • A2AAgent is a suspending factory, and A2AAgentImpl is internal, so the
    factory is the only way to build one. There's also a non-suspending overload
    taking an AgentCard directly, which the page mentions.
  • Badge is unversioned (Kotlin, not Kotlin v0.6.0), matching every other
    page in this section — and avoiding a contradiction with the 0.7.0 dependency
    the page tells you to add.
  • Transcluded and registered, so CI compiles and lints the snippet.

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:

GET /.well-known/agent-card.json
Root agent root_agent delegates to prime_agent

So the factory fetched the card, parsed it, and the remote agent was accepted as
a sub-agent. verify_snippets.py passes all six levels.

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".
@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploy Preview for adk-docs-preview ready!

Name Link
🔨 Latest commit 42033d2
🔍 Latest deploy log https://app.netlify.com/projects/adk-docs-preview/deploys/6a7f805cbe79b900085cf9c2
😎 Deploy Preview https://deploy-preview-2118--adk-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@happyhuman happyhuman self-assigned this Aug 11, 2026
Comment thread docs/a2a/quickstart-consuming-kotlin.md Outdated

## Connect to the remote agent

`A2AAgent` fetches that card and reads the remote agent's name, description and

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@happyhuman
happyhuman requested a review from wikaaaaa August 14, 2026 20:52
@happyhuman

Copy link
Copy Markdown
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants