From 9f6eea0f7034a4b380910d02be63fb38315c1ef4 Mon Sep 17 00:00:00 2001 From: Shahin Saadati Date: Thu, 20 Aug 2026 09:26:25 -0700 Subject: [PATCH 1/2] Add Kotlin tabs for grounding with Agent Search Both tab groups on the page showed Python and Java only, though VertexAiSearchTool has existed in adk-kotlin since v0.1.0. Kotlin uses the constructor directly rather than the builder the Java tab reaches for, since dataStoreId is a named parameter. The citation snippet collects from the event Flow instead of iterating a list, and reads isFinalResponse as a property. Both tabs are inline, matching their siblings: the snippets elide surrounding setup and carry placeholder datastore ids, so there is nothing here that could compile standalone. --- docs/grounding/grounding_with_search.md | 44 ++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/docs/grounding/grounding_with_search.md b/docs/grounding/grounding_with_search.md index cea516bc33..e3b28b9770 100644 --- a/docs/grounding/grounding_with_search.md +++ b/docs/grounding/grounding_with_search.md @@ -1,7 +1,7 @@ # Grounding with Search for agents
- Supported in ADKPython v0.1.0Java v0.1.0 + Supported in ADKPython v0.1.0Java v0.1.0Kotlin v0.8.0
[Agent Search](/integrations/agent-search/) is a powerful tool for the Agent Development Kit (ADK) that enables AI agents to access information from your private enterprise documents and data repositories. By connecting your agents to indexed enterprise content, you can provide users with answers grounded in your organization's knowledge base. @@ -70,6 +70,32 @@ To enable Grounding with Search, you include the search tool in your agent defin .build(); ``` +=== "Kotlin" + + ```kotlin + import com.google.adk.kt.agents.Instruction + import com.google.adk.kt.agents.LlmAgent + import com.google.adk.kt.models.Gemini + import com.google.adk.kt.tools.VertexAiSearchTool + + // Configuration + val DATASTORE_ID = + "projects/YOUR_PROJECT_ID/locations/global/collections/default_collection/dataStores/YOUR_DATASTORE_ID" + + val rootAgent = + LlmAgent( + name = "vertex_search_agent", + model = Gemini(name = "gemini-flash-latest"), + instruction = + Instruction( + "Answer questions using Agent Search to find information from internal " + + "documents. Always cite sources when available.", + ), + description = "Enterprise document search assistant with Agent Search capabilities", + tools = listOf(VertexAiSearchTool(dataStoreId = DATASTORE_ID)), + ) + ``` + ## How Grounding with Search works Grounding with Search is the process that connects your agent to your organization's indexed documents and data, allowing it to generate accurate responses based on private enterprise content. When a user's prompt requires information from your internal knowledge base, the agent's underlying LLM intelligently decides to invoke the `VertexAiSearchTool` to find relevant facts from your indexed documents. @@ -196,6 +222,22 @@ Since grounding metadata is provided, you can choose to implement citation displ } ``` +=== "Kotlin" + + ```kotlin + events.collect { event -> + if (event.isFinalResponse) { + println(event.content?.parts?.firstOrNull()?.text) + + // Optional: Show source count + val chunks = event.groundingMetadata?.groundingChunks + if (!chunks.isNullOrEmpty()) { + println("\nBased on ${chunks.size} documents") + } + } + } + ``` + **Enhanced Citation Display (Optional):** You can implement interactive citations that show which documents support each statement. The grounding metadata provides all necessary information to map text segments to source documents. ### Implementation Considerations From 837d0f155f50af93b4fc592cea9d00aecfa54ce9 Mon Sep 17 00:00:00 2001 From: Shahin Saadati Date: Thu, 20 Aug 2026 11:21:54 -0700 Subject: [PATCH 2/2] Badge the grounding page with the version VertexAiSearchTool shipped in The badge said Kotlin v0.8.0, the version adk-docs compiles against, rather than the introducing release. VertexAiSearchTool has been present since v0.1.0, matching the Python v0.1.0 and Java v0.1.0 badges already on this page. --- docs/grounding/grounding_with_search.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/grounding/grounding_with_search.md b/docs/grounding/grounding_with_search.md index e3b28b9770..552aa6b9a9 100644 --- a/docs/grounding/grounding_with_search.md +++ b/docs/grounding/grounding_with_search.md @@ -1,7 +1,7 @@ # Grounding with Search for agents
- Supported in ADKPython v0.1.0Java v0.1.0Kotlin v0.8.0 + Supported in ADKPython v0.1.0Java v0.1.0Kotlin v0.1.0
[Agent Search](/integrations/agent-search/) is a powerful tool for the Agent Development Kit (ADK) that enables AI agents to access information from your private enterprise documents and data repositories. By connecting your agents to indexed enterprise content, you can provide users with answers grounded in your organization's knowledge base.