Skip to content

Default value is not supported in function declaration schema for Google AI #3275

@namanrajpal

Description

@namanrajpal

Describe the bug

Default parameter values in function tool declarations cause errors when using Google AI (Gemini API) but work correctly with Vertex AI. The ADK documentation states that default values are supported for optional parameters, but the implementation appears to have variant-specific behavior that isn't documented.

To Reproduce

  1. Install ADK: pip install google-adk

  2. Create a function tool with default parameters:

from google.adk.tools import FunctionTool

async def find_something(
    tool_context: ToolContext,
    query: str = "",
    category: str = "",
    important_only: bool = False,
    limit: int = 10,
) -> dict:
    """Find something ...."""
    # implementation
    pass

some_tools = {
    "find_something": FunctionTool(func=find_something),
}
  1. Configure agent to use Google AI (Gemini API):
llm_config:
  provider: google
  model: gemini-2.5-flash
  api_key_secret_name: GOOGLE_API_KEY
  1. Run the agent and attempt to use the tool

  2. Warning appears: "Default value is not supported in function declaration schema for Google AI" and tool calls don't work.

Expected behavior

According to the ADK documentation at https://google.github.io/adk-docs/tools/function-tools/, optional parameters with default values should be supported:

"A parameter is considered optional if you provide a default value. This is the standard Python way to define optional arguments. The ADK correctly interprets these and does not list them in the required field of the tool schema sent to the LLM."

The tool should work with default parameters regardless of whether using Vertex AI or Gemini API.

Actual behavior

The code in .venv/lib/python3.11/site-packages/google/adk/tools/_function_parameter_parse_util.py https://github.com/google/adk-python/blob/main/src/google/adk/tools/_function_parameter_parse_util.py#L76 appears to have variant-specific logic that rejects default values for Gemini API but accepts them for Vertex AI.

Setting environment variable GOOGLE_GENAI_USE_VERTEXAI=true might make it work, but this isn't a viable solution for users who need to use Gemini API.

Desktop Information:

  • OS: macOS
  • Python version: 3.11
  • ADK version: 1.16.0

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-2.5-flash (also fails with gemini-2.5-pro)

Additional context

This issue affects the usability of function tools for users relying on Gemini API. The documentation should either:

  1. Clearly state that default parameters are only supported with Vertex AI
  2. Or fix the implementation to support default parameters for both variants

The current behavior creates confusion as the documented feature doesn't work as expected for Gemini API users.

Metadata

Metadata

Labels

core[Component] This issue is related to the core interface and implementation

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions