Skip to content

sanitizeToolsForGoogle() does not sanitize tools for google-generative-ai provider #20197

@peterhemstitch

Description

@peterhemstitch

Bug Description

sanitizeToolsForGoogle() only sanitizes JSON Schema keywords (like patternProperties, additionalProperties, $ref) for a subset of Google providers, missing google-generative-ai.

Current Behavior

Version 2026.2.17:

if (params.provider !== "google-gemini-cli") return params.tools;

Version 2026.2.15:

if (params.provider !== "google-antigravity" && params.provider !== "google-gemini-cli") return params.tools;

Neither version sanitizes tools when params.provider === "google-generative-ai", causing raw patternProperties to be sent to the Google API.

Error

Cloud Code Assist API error (400): Invalid JSON payload received. 
Unknown name "patternProperties" at 'request.tools[0].function_declarations[3].parameters.properties[2].value': Cannot find field.

Expected Behavior

All Google providers should be sanitized. A simple fix:

if (!params.provider?.startsWith("google")) return params.tools;

This covers google-generative-ai, google-gemini-cli, and google-antigravity in one check.

Environment

  • OpenClaw 2026.2.17 (also affects 2026.2.15)
  • Provider: google-generative-ai (API keys from Google AI Studio)
  • The function exists in multiple bundled JS files (reply-*.js, pi-embedded-*.js, plugin-sdk/reply-*.js)

Workaround

Patch all JS files in the container with sed:

sed -i 's/params.provider !== "google-gemini-cli"/!params.provider?.startsWith("google")/g' /path/to/openclaw/dist/*.js

Note: patch does not survive container recreation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions