Skip to content

Add Kotlin tabs to the tool confirmation page - #2157

Open
happyhuman wants to merge 2 commits into
mainfrom
docs-kotlin-tool-confirmation
Open

Add Kotlin tabs to the tool confirmation page#2157
happyhuman wants to merge 2 commits into
mainfrom
docs-kotlin-tool-confirmation

Conversation

@happyhuman

@happyhuman happyhuman commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

What

Adds Kotlin to all three tab groups on docs/tools-custom/confirmation.md (boolean, dynamic/threshold, advanced), plus the Kotlin v0.1.0 badge and two prose updates that previously listed every language except Kotlin.

New snippets, both registered in files_to_test.txt:

  • examples/kotlin/snippets/tools/confirmation/ToolConfirmationExample.kt — boolean + advanced
  • examples/kotlin/snippets/tools/confirmation/dynamic/ReimbursementTools.kt — threshold

One correction to the tracking notes

The backlog entry for this row said there is no confirmation support to mirror and warned against inventing one. The first half turned out to be wrong: @Tool(requireConfirmation = true) exists at v0.8.0 and the KSP processor forwards it to FunctionTool(requiresConfirmation = ...). So the boolean tab is a direct equivalent of Python's FunctionTool(require_confirmation=True), not a hand-rolled workaround. The warning itself still held — there is no separate confirmation tool type, and none was invented.

Deliberate divergences from the sibling tabs

  • Dynamic gating happens inside the tool. The annotation flag is a compile-time constant, and @Tool has no predicate form, so the threshold is evaluated with ToolContext exactly as the Java tab does. Called out in a note on the tab and in the section prose.
  • The advanced example reads the payload through Number. ToolConfirmation.payload is Any? and arrives decoded from JSON, so its numeric type is not guaranteed. Casting straight to Int would be a latent ClassCastException; this is the same hazard the Go tab flags for float64.

Why two files

@Tool generates a wrapper class named after the function, in the function's package. The boolean and threshold examples are both naturally called reimburse, which would collide. Rather than rename one in a way that would read as meaningful, the threshold example lives in its own package — the package line sits outside the transcluded region, so both tabs show a plainly named reimburse.

Verification

Grounded against the v0.8.0 git tag. Full ladder green (L0, L1 compile with KSP, L2 ktlint, L3, L5, L6). L4 runSnippets reports SKIP — no such Gradle task exists in this repo.

Tracked as KT-24.


Update: the badge originally read Kotlin v0.8.0, which is the version adk-docs compiles against, not the release the feature shipped in. Corrected to the introducing version, matching the sibling badges and the rest of the site.

All three tab groups showed Python, TypeScript, Go and Java but not
Kotlin, even though the API has existed since adk-kotlin v0.1.0.

Kotlin turns out to sit closer to Python than to TypeScript here: the
@tool annotation carries a requireConfirmation flag, so the boolean case
is a direct equivalent of FunctionTool(require_confirmation=True) rather
than something callers hand-roll. The flag is a compile-time constant,
though, so dynamic thresholds are evaluated inside the tool through
ToolContext, the way ADK Java does it. The prose that previously singled
out TypeScript for that now names Kotlin too.

The advanced example reads the returned payload through Number rather
than casting straight to Int, because the payload arrives decoded from
JSON and its numeric type is not guaranteed - the same trap the Go tab
calls out for float64.
@netlify

netlify Bot commented Aug 20, 2026

Copy link
Copy Markdown

Deploy Preview for adk-docs-preview ready!

Name Link
🔨 Latest commit d327559
🔍 Latest deploy log https://app.netlify.com/projects/adk-docs-preview/deploys/6a8745bcdb25230007017b23
😎 Deploy Preview https://deploy-preview-2157--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 20, 2026
The badge said Kotlin v0.8.0, the version adk-docs compiles against,
rather than the introducing release. ToolConfirmation,
ToolContext.requestConfirmation and the @tool requireConfirmation flag
were all present at v0.1.0.
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.

1 participant