Skip to content

Feat: add bypassMultiToolsLimit and model constructor options to GoogleSearchTool - #714

Open
AmaadMartin wants to merge 2 commits into
mainfrom
feat/google-search-tool-constructor-options
Open

Feat: add bypassMultiToolsLimit and model constructor options to GoogleSearchTool#714
AmaadMartin wants to merge 2 commits into
mainfrom
feat/google-search-tool-constructor-options

Conversation

@AmaadMartin

Copy link
Copy Markdown
Owner

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

  1. Link to an existing issue (if applicable):
    N/A
  2. Or, if no issue exists, describe the change:
    Problem: adk-python's GoogleSearchTool.__init__ accepts bypass_multi_tools_limit and model. adk-js exposes neither, so a user cannot attach Google Search alongside other tools on a Gemini 1.x model, and cannot pin the tool to a model other than the one on the request.

Solution: GoogleSearchTool now takes an optional GoogleSearchToolParams object. bypassMultiToolsLimit gates the Gemini 1.x multi-tool throw, and model overwrites llmRequest.model as the first statement of processLlmRequest, before the early-return guard, so an override works on a request that carries no model. new GoogleSearchTool() and the GOOGLE_SEARCH singleton are unchanged, and no existing test was modified.

Parity note: model matches adk-python exactly. bypassMultiToolsLimit follows the adk-js VertexAiSearchTool meaning (skip the Gemini 1.x multi-tool guard), not the adk-python meaning (opt in to agent-tool wrapping in LlmAgent), because adk-js has no such wrapping path. Reference: src/google/adk/tools/google_search_tool.py and tests/unittests/tools/test_google_search_tool.py in google/adk-python.

Collision check: I listed the open pull requests on this fork before starting. #614 edits the same method for ADK_DISABLE_GEMINI_MODEL_ID_CHECK, and #638 and #332 touch neighbouring lines. None of them adds a constructor option, so this branches from main. The new tests sit at the end of the processLlmRequest describe block to keep the overlap with #614 to one insertion point.

Testing Plan

Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.

npx vitest run --project unit:core core/test/tools/google_search_tool_test.ts — 15 passed.
npx vitest run --project unit:core core/test/tools/vertex_ai_search_tool_test.ts — 10 passed (the sibling tool that shares the flag name is untouched).

Coverage of core/src/tools/google_search_tool.ts: 100% branch, 95.65% line. The two uncovered lines are the pre-existing runAsync() body, which this change does not touch. Every new line and branch is covered.

Mutation testing. I ran each mutation, confirmed the failure, then reverted:

  1. Delete && !this.bypassMultiToolsLimit — "skips the Gemini 1.x multi-tool check when bypassMultiToolsLimit is true" fails with Google search tool can not be used with other tools in Gemini 1.x.
  2. Delete the if (this.model !== undefined) block — 3 tests fail: "applies a Gemini 1.x model override to a Gemini 2+ request", "applies a Gemini 2+ model override to a Gemini 1.x request", "applies the model override when the request carries no model".
  3. Move the override below the if (!llmRequest.model) return; guard — "applies the model override when the request carries no model" fails with expected [] to deeply equal [ { googleSearch: {} } ]. This is the ordering the other two mutations do not catch.

Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.

npm run build
npm run lint          # clean
npm run format:check  # clean
npm run docs:check    # clean; confirms GoogleSearchToolParams is exported for TypeDoc
npx vitest run --project unit:core core/test/tools/google_search_tool_test.ts

npm run ts:check reports 279 errors, all pre-existing and unrelated. The same command on main reports 280. This branch removes one of them: widening the makeRequest tools parameter to Tool[] fixes the never[] inference that already broke the line-46 test.

Checklist

[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.

Amaad Martin added 2 commits August 6, 2026 03:58
Give GoogleSearchTool an optional options-object constructor so callers can
skip the Gemini 1.x multi-tool guard and pin the tool to a specific model.
Both fields are read in processLlmRequest. Zero-argument construction and the
GOOGLE_SEARCH singleton are unchanged.
Append eight cases for the bypass flag, the model override and the defaults.
The makeRequest tools parameter is widened to Tool[] so the new multi-tool
cases type-check; no existing test is modified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant