Skip to content

Google provider: JSON Schema 'const' in tool schemas causes Pydantic/Gemini errors #420

@xek

Description

@xek

Running with the Google provider fails because tool parameter schemas include JSON Schema 'const'. This triggers either Pydantic validation errors or a Gemini API 400.

To reproduce:

  1. Run:
    uvx fast-agent-mcp go --model google.gemini-2.5-pro --uvx wcgw
  2. Type: hi

Observed errors

  • Pydantic validation (before provider request):
    ValidationError: ... properties.*.const ... Extra inputs are not permitted

  • Gemini API (after getting past Pydantic):
    Google API Error: 400
    Invalid JSON payload received. Unknown name "const" at ...parameters...

Environment

  • OS: Linux (Fedora) x86_64
  • Python: 3.13
  • uv: 0.8.23
  • fast-agent-mcp: latest via uvx
  • Model: google.gemini-2.5-pro

Notes

  • Offending places include fields like allowed_globs / allowed_commands that use const: "all".
  • google.genai function_declarations don’t accept 'const'; Pydantic may also reject it.

Workaround verified locally

  • In src/fast_agent/llm/provider/google/google_converter.py:
    • If const is a string, rewrite to enum: [value].
    • If const is non-string, drop the constraint to avoid Gemini 400.
  • With this, the repro initializes and responds.

Proposal

  • Update _clean_schema_for_google to rewrite/remove 'const' as above (and continue stripping other unsupported keys).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions