镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Feature Request: Native AFC & Multi-Tool Combination Support (Built-in Grounding + Custom Python Callables) on Vertex AI #5772

Closed

Description

@avadlapatla

Feature Request: Native AFC & Multi-Tool Combination Support (Built-in Grounding + Custom Python Callables) on Vertex AI

Please make sure you read the contribution guide and file the issues in the right place.
Contribution guide.


🔴 Required Information

Please ensure all items in this section are completed to allow for efficient triaging. Requests without complete information may be rejected / deprioritized. If an item is not applicable to you - please mark it as N/A

Is your feature request related to a specific problem?

Yes. When building agentic workflows in ADK 2.0.0, developers frequently need to mix built-in server-side grounding tools (like google_maps_grounding or google_search) with custom client-side Python callables in a single agent.

Currently, doing so on the Vertex AI backend causes the underlying google-genai SDK client validator to automatically disable Automatic Function Calling (AFC) and log a repetitive, confusing RuntimeWarning on every single model turn:

Tools at indices [1] are not compatible with automatic function calling (AFC).
AFC is disabled. If AFC is intended, please include python callables in the tool
list, and do not include function declaration and MCP server in the tool list.

Although the ADK framework successfully bypasses this SDK block by using its own custom Manual Function Calling (MFC) history-circulation loop inside InMemoryRunner (allowing the execution to complete successfully on single-region endpoints like us-central1), the warning creates substantial console noise for ADK developers, and completely breaks native AFC capability for direct GenAI SDK developers.


Describe the Solution You'd Like

We would like native support for mixing built-in grounding search tools and custom client-side callable function tools cleanly without warnings or disabled AFC.

Proposed Solutions:

  1. In the google-genai Python SDK:

    • Update find_afc_incompatible_tool_indexes(): Modify the validator (google/genai/_extra_utils.py:L121) to keep client-side AFC active for custom FunctionDeclarations as long as the executable Python callables are registered in the client's local function_map.
    • Allow include_server_side_tool_invocations on Vertex AI: Permit this context-circulation configuration flag on Vertex AI (models.py:L4135 inside _ToolConfig_to_vertex()) for Gemini 3 models on the v1beta1 endpoint, rather than hardcoding a client-side ValueError crash.
  2. In the google-adk Python SDK:

    • Grounding Bypass Sub-agent Wrapper: Create a GoogleMapsGroundingAgentTool class that automatically wraps google_maps_grounding inside an isolated sub-agent tool under the hood when bypass_multi_tools_limit=True is specified (identical to how the ADK currently bypasses the limit for the standard GoogleSearchTool in llm_agent.py:L149).

Impact on your work

This feature is important for enabling clean, warning-free enterprise agentic implementations on Vertex AI. Bypassing this client-side warning will significantly improve the developer experience and adoption when building mixed-tool workflows (combining built-in search grounding and custom business tools) under the ADK 2.0 framework.


Willingness to contribute

No, but we are highly interested in collaborating, providing additional logs, and validating potential preview/beta fixes in our Google Cloud workspaces.


🟡 Recommended Information

Describe Alternatives You've Considered

Alternative A: The Context Injection Pattern

  • What we did: Fetched the custom data (such as Client IP or CRM profiles) locally in Python inside run.py prior to calling the agent, and injected it as text context (e.g., [Client IP: X.X.X.X]).
  • Why it's not ideal: While this works and completely avoids warning logs, it strips the model of its agentic autonomy. The model cannot dynamically decide when to call the custom tool mid-workflow based on conversation logic.

Alternative B: ADK's Manual Interception (MFC Fallback)

  • What we did: Let the ADK Runner manually intercept the function_call and route the function_response loop.
  • Why it's not ideal: While it executes successfully on single-region endpoints (like us-central1), it floods the console logs with repetitive, multi-line SDK compatibility warning blocks on every query turn.

Proposed API / Implementation

In google.adk.tools, we would like to be able to initialize the maps grounding tool with a bypass flag:

from google.adk.tools import google_maps_grounding

# Automatically wraps maps grounding inside a sub-agent tool under the hood
google_maps_grounding.bypass_multi_tools_limit = True

This should be handled in google/adk/agents/llm_agent.py similarly to the standard GoogleSearchTool logic:

# Proposed addition inside _convert_tool_union_to_tools() in llm_agent.py:
if multiple_tools and isinstance(tool_union, GoogleMapsGroundingTool):
    from ..tools.google_maps_grounding_agent_tool import create_maps_agent
    from ..tools.google_maps_grounding_agent_tool import GoogleMapsGroundingAgentTool

    maps_tool = cast(GoogleMapsGroundingTool, tool_union)
    if maps_tool.bypass_multi_tools_limit:
        return [GoogleMapsGroundingAgentTool(create_maps_agent(model))]

Additional Context

ADK & GenAI Environment Details:

  • ADK Library Version: 2.0.0 (GA)
  • GenAI SDK Version: 1.75.0
  • Python Version: 3.13
  • Desktop OS: Linux
  • Model: gemini-3.5-flash (Vertex AI, us multi-region)

Live timing logs on the 'us' multi-region endpoint showing the successful manual intercept loop working despite the disabled AFC warning:

Tools at indices [1] are not compatible with automatic function calling (AFC).
AFC is disabled. If AFC is intended, please include python callables in the tool
list, and do not include function declaration and MCP server in the tool list.
  ⚡ 🗺️ Google Maps Grounding Retrieval (+6.97s)
[DATABASE LOG] Saving: The Pink Door (4.6★) at 1919 Post Alley, Seattle, WA 98101, USA
  ⚡ 🧠 concierge_agent (function_response) (+0.00s)
  ⚡ 🧠 concierge_agent (function_call) (+2.12s)
  ⚡ 🧠 concierge_agent (function_response) (+0.13s)
  ⚡ 🏁 Response Synthesis & Completion (+4.64s)

Activity

  1. added
    tools[Component] This issue is related to tools
    on May 21, 2026
  2. added theissue type on May 21, 2026
  3. klateefa commented on May 21, 2026

    @klateefa

    @avadlapatla Thanks for the update. The request is currently being reviewed by our team, and I will let you know if anything further is needed. Thank you for your understanding.

  4. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on May 21, 2026
  5. DeanChensj commented on Oct 13, 2026

    @DeanChensj
    Collaborator

    Thank you for the detailed report and reproduction steps!

    Here is how ADK handles combining built-in grounding tools with custom Python function tools, and why you saw the two behaviors described in the issue:

    1. Native Multi-Tool Combination (Built-in Grounding + Custom Tools) on Gemini 3+:
      In src/google/adk/utils/model_name_utils.py (is_gemini_3_or_above) and src/google/adk/flows/llm_flows/extensions/_agent_transfer.py, Gemini 3+ models natively support combining built-in grounding tools (such as GoogleSearchTool, VertexAiSearchTool, EnterpriseWebSearchTool, and GoogleMapsGroundingTool) with custom Python function declarations in the same request without needing a wrapper sub-agent.

      • On older Gemini 2.x models, the Vertex AI / Gemini backend itself rejects requests that combine built-in grounding tools with custom function_declarations in a single GenerateContent call unless the built-in tool is isolated in a sub-agent or AgentTool (which is what GoogleSearchTool(bypass_multi_tools_limit=True) and VertexAiSearchTool(bypass_multi_tools_limit=True) do under the hood, or you can wrap an agent with google_maps_grounding inside AgentTool(agent=maps_agent)).
    2. Why google-genai logged the AFC warning:
      The warning Tools at indices [1] are not compatible with automatic function calling (AFC). AFC is disabled. comes from the underlying google-genai SDK when raw Python callables are passed inside GenerateContentConfig(tools=[...]) alongside a types.Tool. In ADK, custom Python callables should be passed to LlmAgent(tools=[...]) (not generate_content_config.tools), because ADK's own BaseLlmFlow orchestrates the tool-execution loop (_functions.py) rather than relying on google-genai's client-side AFC loop.

    We are closing this issue with the above solution. Please feel free to reopen it if you still encounter any issues when registering your tools on LlmAgent(tools=[...])!

  6. github-actions commented on Oct 13, 2026

    @github-actions

    Are you satisfied with the resolution of your issue?
    Yes
    No

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

Metadata

Metadata

Assignees

Labels

needs review[Status] The PR/issue is awaiting review from the maintainertools[Component] This issue is related to tools

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions