Files
Shahin Saadati 12c70c7106 Add Kotlin snippets for Memory Bank and RAG memory (#2089)
* Upgrade Kotlin examples to adk-kotlin 0.7.0

The Kotlin examples were pinned to adk-kotlin 0.5.0, which predates the
context caching, Vertex AI memory, and RAG retrieval APIs. Bump the pin to
0.7.0 so snippets for those features can be added.

Three consequences of the bump are handled here:

- `ExperimentalResumabilityFeature` was removed in 0.7.0, so RunConfigExample
  no longer opts into it. The annotation class is gone, not merely deprecated,
  so this is a hard compile break rather than a warning that could be deferred.
- The Vertex AI session and memory services expose Ktor's `HttpClient` as a
  defaulted constructor parameter, so any snippet naming them needs Ktor on the
  compile classpath, not just at runtime.
- The `resolutionStrategy` block forcing kotlin-stdlib 2.1.20 is now dead. It
  worked around 0.5.0 publishing a stdlib newer than this project's compiler;
  0.6.0 fixed that upstream. Verified that the highest stdlib on the compile
  classpath is still 2.1.20 without it.

Also fixes two unrelated snags found while validating the above:

- `check_kotlin_snippets.sh` walked `examples/kotlin` without pruning build
  output, so after any local build it reported every generated KSP file as an
  unregistered snippet. CI only ever ran it against a clean checkout, so the
  bug was invisible there.
- A transclusion path in logging.md was split across two lines, so the include
  never resolved and the code block rendered empty.

* Fix broken links to adk-python plugin samples

The three plugin sample links 404. adk-python renamed
`contributing/samples/plugin/` to `contributing/samples/plugins/`; the
directory contents are otherwise unchanged, so only the path segment moves.

This is what the repo-wide `link-check` job has been failing on. It is
unrelated to the 0.7.0 upgrade in this PR, but the check gates the merge and
the fix is confined to the three URLs.

Verified all three targets return 200.

* Add Kotlin snippets for Memory Bank and RAG memory

The memory page documented `VertexAiMemoryBankService` and
`VertexAiRagMemoryService` for Python and Java only; the Kotlin tab stopped at
the in-memory service. Both are available in adk-kotlin as of 0.7.0, so add
the two missing tabs.

Both services declare an `internal` primary constructor, so the snippets use
the public secondary one that takes project/location plus the engine or corpus
id -- reading the primary signature alone gives a constructor callers cannot
invoke.

The page's language-support badge stays at Kotlin v0.1.0: it marks when Kotlin
support for the page was introduced, and the other six Kotlin snippets on it
have worked since then.

The remaining diff in MemoryExample.kt is ktlint bringing pre-existing lines
into line with the repo style, which the linter now gates on because the file
is touched here.

* Correct the ragCorpus contract and wire both services to a Runner

Three fixes from review:

- The `rag_memory` KDoc claimed `ragCorpus` accepts a bare id or a full
  resource name. It is the opposite: `normalizeCorpusName` does
  `require(!ragCorpus.startsWith("projects/"))` and throws on a full name. The
  Python tab directly above this snippet passes a full resource name, so a
  reader switching tabs would have hit an IllegalArgumentException with a
  comment telling them it was fine. The note now states the bare-id rule and
  calls out the divergence from Python explicitly.
- Dropped "the primary constructor is internal" from the rendered snippet. It
  is a note for reviewers, not for readers, who cannot see that constructor.
  It stays in the PR description.
- Both snippets stopped at a factory function while the surrounding prose says
  "instantiating the service and passing it to the Runner" and the Python tab
  shows exactly that. They now build the service and pass it to a Runner.
2026-08-10 08:29:26 -07:00
..