Skip to content

DiscoveryEngineSearchTool: 400 error with regional (non-global) data stores #4697

Closed

Description

@kaligautier

Description

DiscoveryEngineSearchTool fails with a 400 error when used with a data store located in a non-global region (e.g. eu).

Error

400 Incorrect API endpoint used. The current endpoint can only serve traffic from "global" region,
but got "eu" region from the API request.
Please follow https://cloud.google.com/generative-ai-app-builder/docs/locations to use the correct regional API endpoint.

Root cause

In discovery_engine_search_tool.py (L75-84), the SearchServiceClient is always created with the default global endpoint (discoveryengine.googleapis.com):

credentials, _ = google.auth.default()
quota_project_id = getattr(credentials, "quota_project_id", None)
options = (
    client_options.ClientOptions(quota_project_id=quota_project_id)
    if quota_project_id
    else None
)
self._discovery_engine_client = discoveryengine.SearchServiceClient(
    credentials=credentials, client_options=options
)

However, regional data stores (e.g. eu, us, or single-region like europe-west1) require regional endpoints such as eu-discoveryengine.googleapis.com, as documented in Discovery Engine locations.

The location is already present in the data_store_id parameter (e.g. projects/{project}/locations/eu/collections/…), but it is never used to configure the client endpoint.

Reproduction

from google.adk.tools import DiscoveryEngineSearchTool

tool = DiscoveryEngineSearchTool(
    data_store_id="projects/my-project/locations/eu/collections/default_collection/dataStores/my-datastore",
)

# Calling the tool triggers a 400 error
result = tool.discovery_engine_search("test query")
# → {"status": "error", "error_message": "400 Incorrect API endpoint used..."}

Expected behavior

The tool should extract the location from data_store_id (or search_engine_id) and set the appropriate api_endpoint in ClientOptions:

  • eu → eu-discoveryengine.googleapis.com
  • us → us-discoveryengine.googleapis.com
  • europe-west1 → europe-west1-discoveryengine.googleapis.com
  • global → discoveryengine.googleapis.com (default, unchanged)

Suggested fix

Parse the location from the resource ID and pass api_endpoint to ClientOptions:

import re

location_match = re.search(r"/locations/([^/]+)/", data_store_id or search_engine_id)
location = location_match.group(1) if location_match else "global"

api_endpoint = (
    f"{location}-discoveryengine.googleapis.com"
    if location != "global"
    else "discoveryengine.googleapis.com"
)

options = client_options.ClientOptions(
    api_endpoint=api_endpoint,
    quota_project_id=quota_project_id,
)

Alternatively, accept an optional client_options or api_endpoint parameter in the constructor to let users override it.

Environment

  • google-adk version: 1.25.1
  • Data store location: eu
  • Python: 3.14

Activity

  1. added
    tools[Component] This issue is related to tools
    on Mar 3, 2026
  2. added theissue type on Mar 3, 2026
  3. llalitkumarrr commented on Mar 4, 2026

    @llalitkumarrr
    Collaborator

    Hello @kaligautier ,

    Have you had a chance to test your fix? If it works well for you, please feel free to raise a PR. We will gladly review it and get it merged if all checks pass.

  4. self-assigned this
    on Mar 4, 2026
  5. added 2 commits that reference this issue on Mar 4, 2026
    d0848e2
    f61c15e
  6. kaligautier commented on Mar 5, 2026

    @kaligautier
    ContributorAuthor

    This europe-west1 → europe-west1-discoveryengine.googleapis.com is not necessary we can keep us eu and global

  7. llalitkumarrr commented on Mar 6, 2026

    @llalitkumarrr
    Collaborator

    Hello @kaligautier ,

    Thank you for your contribution, we will review this and if all checks pass it will be merged.

  8. llalitkumarrr commented on Mar 6, 2026

    @llalitkumarrr
    Collaborator

    Hello @rohityan , could you please have look at this?

  9. chc4abt commented on Mar 12, 2026

    @chc4abt

    Hi, I am also facing this issue when using VertexAISearchTool with bypass_multi_tools_limit being set to True: https://google.github.io/adk-docs/tools/limitations/#workaround-2-bypass_multi_tools_limit
    When do we expect the issue to be solved?

  10. removed their assignment
    on Mar 16, 2026
  11. xuanyang15 commented on Mar 16, 2026

    @xuanyang15
    Collaborator

    bypass_multi_tools_limit and DiscoveryEngineSearchTool were introduce as a workaround for the model's limitation that built-in tools cannot be used with other tools together. Since new Gemini models no longer have the limitation, could you please switch to use the built in VertexAiSearchTool?

  12. chc4abt commented on Mar 17, 2026

    @chc4abt

    Since we are EU based the application need to follow GDPR and EU AI act. Gemini 3 and Gemini 3.1 is not available through location EU. So we would appreciate the workaround to be fixed to be compatible again with eu located DiscoveryEngineToolSearchTool and Gemini Enterprise application

  13. added a commit that references this issue on Mar 22, 2026
    d699e73
  14. xuanyang15 commented on Mar 23, 2026

    @xuanyang15
    Collaborator

    Thanks for the information! #4720 is under review now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

tools[Component] This issue is related to tools

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions