From 9f6eea0f7034a4b380910d02be63fb38315c1ef4 Mon Sep 17 00:00:00 2001 From: Shahin Saadati Date: Thu, 20 Aug 2026 09:26:25 -0700 Subject: [PATCH 1/4] 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/4] 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. From 30e94f198d41f24080cfced696419eb98477179e Mon Sep 17 00:00:00 2001 From: Shahin Saadati <3443249+happyhuman@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:28:26 +0000 Subject: [PATCH 3/4] Cover Kotlin in the Agent Search authentication setup Kotlin reads the same Google Cloud credentials and env vars as Java from the application environment, so the auth bullet now names both. Also corrects the Kotlin support tag: VertexAiSearchTool landed in v0.2.0, not v0.1.0. --- docs/grounding/grounding_with_search.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/grounding/grounding_with_search.md b/docs/grounding/grounding_with_search.md index 552aa6b9a9..01dc80604a 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.1.0 + Supported in ADKPython v0.1.0Java v0.1.0Kotlin v0.2.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. @@ -19,7 +19,7 @@ Before creating a grounded agent, you must have an existing Agent Search Data St * Set up the [gcloud CLI](https://cloud.google.com/vertex-ai/generative-ai/docs/start/quickstarts/quickstart-multimodal#setup-local) * Authenticate to Google Cloud, from the terminal by running `gcloud auth login`. * For Python, open the **`.env`** file and specify your project ID and location. -* For Java, ensure your application environment has Google Cloud default credentials configured (`GOOGLE_APPLICATION_CREDENTIALS`). +* For Java and Kotlin, ensure your application environment has Google Cloud default credentials configured (`GOOGLE_APPLICATION_CREDENTIALS`), and set the variables below in that same environment rather than in a `.env` file. ```env title=".env" GOOGLE_GENAI_USE_ENTERPRISE=TRUE From 1a55cd8ed06c3f7516e7faa2a5dfb49dfb2c049a Mon Sep 17 00:00:00 2001 From: Joe Fernandez <931947+joefernandez@users.noreply.github.com> Date: Fri, 28 Aug 2026 16:48:45 -0700 Subject: [PATCH 4/4] Apply suggestion from @joefernandez --- 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 01dc80604a..55b4d123bc 100644 --- a/docs/grounding/grounding_with_search.md +++ b/docs/grounding/grounding_with_search.md @@ -14,7 +14,7 @@ Before creating a grounded agent, you must have an existing Agent Search Data St ## Authentication Setup -**Note: Agent Search requires Google Cloud Platform (Agent Platform) authentication. Google AI Studio is not supported for this tool.** +Agent Search requires your ADK agent to be connected to a Google Cloud project authentication. You can not use a Gemini API Key from Google AI Studio when using this tool. For more information on connecting your ADK agent to Google Cloud projects, see the [Connect to Google Cloud](/get-started/google-cloud/) guide. * Set up the [gcloud CLI](https://cloud.google.com/vertex-ai/generative-ai/docs/start/quickstarts/quickstart-multimodal#setup-local) * Authenticate to Google Cloud, from the terminal by running `gcloud auth login`.