Add Kotlin snippet for token-threshold context compaction - #2107
Merged
Conversation
The compaction page had no Kotlin at all. EventsCompactionConfig gained tokenThreshold and eventRetentionSize in adk-kotlin 0.6.0, so the Kotlin tab shows that pair, matching the TypeScript tab's strategy. Kotlin sits across the two groupings the prose already draws: the config attaches to App, as in Python and Java, but supports the token-threshold pair like TypeScript. Both parentheticals are updated to say so rather than adding new prose. The snippet notes that tokenThreshold and eventRetentionSize must be set together. That is a runtime require, not a compile error, so it is easy to hit: setting one alone throws "tokenThreshold and eventRetentionSize must be set together or both null". The same rule applies to compactionInterval and overlapSize, which Kotlin also supports. Badged Kotlin v0.7.0 rather than 0.6.0, when the fields landed: appName is "my-agent" to match the sibling tabs, and hyphens in app names were only allowed from 0.7.0. Inline to match the page's other tabs, so CI will not compile it. Extracted, compiled and ran it against the 0.7.0 pin in a throwaway project: OK app=my-agent tokenThreshold=1000 retention=1 paired=true.
✅ Deploy Preview for adk-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
happyhuman
force-pushed
the
docs-kotlin-compaction-token-threshold
branch
from
August 10, 2026 21:57
975e216 to
fadd5bf
Compare
Self-review finding. The Kotlin tab shows tokenThreshold/eventRetentionSize while Python and Java show compactionInterval/overlapSize, so a reader comparing tabs could conclude the strategy is fixed per language. It is not: EventsCompactionConfig accepts either pair, and exposes hasTokenThresholdConfig and hasSlidingWindowConfig for each.
happyhuman
force-pushed
the
docs-kotlin-compaction-token-threshold
branch
from
August 10, 2026 22:13
fadd5bf to
81001b9
Compare
wikaaaaa
approved these changes
Aug 11, 2026
joefernandez
approved these changes
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docs/context/compaction.mdhad no Kotlin content at all.EventsCompactionConfiggained
tokenThresholdandeventRetentionSizein adk-kotlin 0.6.0, so thisadds a Kotlin tab to the "Configure context compaction" group and Kotlin to the
page badge.
One tab, +22/−3.
Notes for reviewers
attaches to
Applike Python and Java, but supports the token-threshold pairlike TypeScript. I updated both parentheticals —
(Python/Java/Kotlin)and(TypeScript/Kotlin)— rather than adding a sentence.require, not a compile error, so it's easyto hit. Setting
tokenThresholdwithouteventRetentionSizethrowstokenThreshold and eventRetentionSize must be set together or both null. Thesnippet says so in one line. The same rule governs
compactionInterval/overlapSize, which Kotlin also supports — this tab shows the token pairbecause that's the newer capability and it mirrors the TypeScript tab.
v0.7.0while Add Kotlin snippet for DebugLoggingPlugin #2105 leftlogging.mdatv0.1.0:logging.mdalready carried a Kotlin badge and Kotlin snippets that work from0.1.0, so raising it would have implied a floor that doesn't apply to them.
This page had no Kotlin badge at all, so the value is set to what a reader
needs to run what's shown.
compactionInterval/overlapSizepairtoo. Showing only the token pair, while Python and Java show only the other,
would otherwise suggest the strategy is fixed per language — it isn't.
Kotlin v0.7.0, not 0.6.0 — the fields landed in 0.6.0, butappName = "my-agent"matches the sibling tabs and hyphens in app names wereonly permitted from 0.7.0 (
App's regex was[a-zA-Z_][a-zA-Z0-9_]*atv0.6.0). Same reasoning as Add Kotlin snippet for context caching configuration #2091.
Verification
Because inline snippets never reach Gradle, I extracted this one, compiled and
ran it against the 0.7.0 pin in a throwaway project — and checked the claim the
comment makes:
and with
eventRetentionSizeremoved:verify_snippets.pypasses L0/L1/L2/L3/L5/L6. API surface read from theadk-kotlin
v0.7.0sources.