openclaw - ✅(Solved) Fix [Bug]: [Bug]: Google Generative AI API error (400) on ALL Google models — thinking=medium sent despite compat flags [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#81424Fetched 2026-05-14 03:32:24
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
1
Author
Timeline (top)
commented ×1cross-referenced ×1labeled ×1

All Google models fail with a generic 400 error. The error hash is identical across every attempt (sha256:56c7a890542e), indicating the same malformed request is being sent every time regardless of model or compat flags.

Error Message

All Google models fail with a generic 400 error. The error hash is identical Sending message on Telegram returns Google Generative AI API error (400)

OpenClaw Error

"error": "Google Generative AI API error (400)", "rawErrorPreview": "Google Generative AI API error (400)", 400 error (request rejected) Gateway returns error to Telegram

Root Cause

All Google models fail with a generic 400 error. The error hash is identical across every attempt (sha256:56c7a890542e), indicating the same malformed request is being sent every time regardless of model or compat flags.

Fix Action

Fixed

PR fix notes

PR #81454: fix(agents): honor disabled reasoning in thinking policy

Description (problem / solution / changelog)

Summary

Fixes #81424 by making an explicit configured model reasoning: false authoritative for thinking policy.

Before this change, configured Google/Gemma models with reasoning: false could still resolve a visible/default thinking policy such as thinking=medium, because the policy resolver only used provider thinking hooks and did not consult configured provider model metadata on the synchronous startup path. The Google transport already guarded against model.reasoning === false; this aligns startup/session thinking policy with that same resolved model capability. Scope note: this branch also carries small CI guardrail/test-fixture updates that were needed to keep the focused thinking-policy change green under the current strictness checks: plugin registry/runtime-config typing strictness and the plugin SDK package-contract guardrail pattern update. Those changes are test/strictness alignment for the same CI run, not new runtime behavior for the thinking-policy fix.

Real behavior proof

Behavior addressed: Configured Google/Gemma models with reasoning: false show thinking=off in startup/session policy and do not send Google generationConfig.thinkingConfig, even if a stale/default reasoning: "medium" option reaches the Google payload builder.

Real environment tested: Local Windows source checkout, rebased branch fix-google-no-thinking-policy.

Exact steps or command run after this patch:

node --import tsx <proof-script>
pnpm test src/auto-reply/thinking.test.ts src/agents/model-selection.test.ts src/gateway/server-startup-log.test.ts extensions/google/transport-stream.test.ts extensions/google/index.test.ts -- --reporter=verbose
pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/auto-reply/thinking.ts src/auto-reply/thinking.test.ts src/agents/model-thinking-default.ts src/agents/model-selection.test.ts src/gateway/server-startup-log.ts src/gateway/server-startup-log.test.ts extensions/google/transport-stream.test.ts
git diff --check

Evidence after fix:

The proof script imports the patched formatAgentModelStartupDetails(...) and buildGoogleGenerativeAiParams(...), configures google/gemma-4-26b-a4b-it with reasoning: false, and passes a stale reasoning: "medium" option into the Google payload builder.

$ node --import tsx <proof-script>
{
  "startupDetails": "thinking=off, fast=off",
  "hasThinkingConfig": false,
  "generationConfig": {
    "maxOutputTokens": 128
  }
}

Targeted regression output:

✓ gateway startup log > shows thinking off for configured provider models with reasoning disabled
✓ model-selection > resolveThinkingDefault > honors configured provider models that disable reasoning
✓ google transport stream > does not send thinkingConfig when the resolved Google model disables reasoning

Test Files  5 passed (5)
Tests  185 passed (185)
[test] passed 4 Vitest shards in 46.14s

Observed result after fix: The startup formatter reports thinking=off, and the Google request payload contains only maxOutputTokens in generationConfig; no thinkingConfig is emitted for the configured non-reasoning Gemma model.

What was not tested: This proof does not call the live Google API or a Telegram-triggered hosted Gateway. It proves the local startup/policy and Google payload-building paths that produced the bad request shape.

Tests

  • pnpm test src/auto-reply/thinking.test.ts src/agents/model-selection.test.ts src/gateway/server-startup-log.test.ts extensions/google/transport-stream.test.ts extensions/google/index.test.ts -- --reporter=verbose
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/auto-reply/thinking.ts src/auto-reply/thinking.test.ts src/agents/model-thinking-default.ts src/agents/model-selection.test.ts src/gateway/server-startup-log.ts src/gateway/server-startup-log.test.ts extensions/google/transport-stream.test.ts
  • git diff --check

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/google/transport-stream.test.ts (modified, +17/-0)
  • src/agents/model-selection.test.ts (modified, +32/-0)
  • src/agents/model-thinking-default.ts (modified, +7/-6)
  • src/auto-reply/thinking.test.ts (modified, +32/-0)
  • src/auto-reply/thinking.ts (modified, +10/-0)
  • src/gateway/server-startup-log.test.ts (modified, +30/-0)
  • src/gateway/server-startup-log.ts (modified, +19/-1)
  • src/plugins/contracts/plugin-sdk-package-contract-guardrails.test.ts (modified, +1/-0)
  • src/plugins/registry.runtime-config.test.ts (modified, +3/-2)
  • src/plugins/registry.ts (modified, +3/-3)

Code Example

NOT_ENOUGH_INFO
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

All Google models fail with a generic 400 error. The error hash is identical across every attempt (sha256:56c7a890542e), indicating the same malformed request is being sent every time regardless of model or compat flags.

Steps to reproduce

Sending message on Telegram returns Google Generative AI API error (400)

Expected behavior

Connection to Gemma models ideally

Actual behavior

OpenClaw is sending thinking/reasoning parameters (thinkingConfig or similar) in the request body that Google's API rejects with 400. The compat flags supportsThinking: false and reasoning: false do not suppress this behavior.

Tested Models (all fail)

  • google/gemini-2.5-flash
  • google/gemma-4-26b-a4b-it
  • google/gemma-4-31b-it

API Key Verification

Key works perfectly via direct curl to native Google API:

curl -s "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=REDACTED"
-H 'Content-Type: application/json'
-X POST
-d '{ "system_instruction": {"parts": [{"text": "You are a helpful assistant."}]}, "contents": [{"role": "user", "parts": [{"text": "Hello"}]}] }'

Response: 200 OK ✅

Provider Config (agents/main/agent/models.json)

{ "baseUrl": "https://generativelanguage.googleapis.com/v1beta", "api": "google-generative-ai", "models": [ { "id": "gemini-2.5-flash", "name": "Gemini 2.5 Flash", "reasoning": false, "compat": { "supportsStore": false, "supportsThinking": false } } ], "apiKey": "GEMINI_API_KEY" }

Gateway Log

[gateway] agent model: google/gemini-2.5-flash (thinking=medium, fast=off)

Gateway reports thinking=medium despite reasoning: false and supportsThinking: false in the model compat config. These flags appear to have no effect.

OpenClaw Error

{ "error": "Google Generative AI API error (400)", "rawErrorPreview": "Google Generative AI API error (400)", "rawErrorHash": "sha256:56c7a890542e", "model": "gemini-2.5-flash", "provider": "google", "providerRuntimeFailureKind": "unclassified" }

OpenClaw version

2026.5.7

Operating system

OS: Ubuntu 24 (Hetzner VPS)

Install method

curl installer

Model

Google AI Studio (Gemini API, api_key mode)

Provider / routing chain

Telegram Message ↓ OpenClaw Gateway (port 18789) ↓ Agent Runtime (agents/main/)

Additional provider/model setup details

Telegram Message ↓ OpenClaw Gateway (port 18789) ↓ Agent Runtime (agents/main/) ↓ reads openclaw.json ← primary model: google/gemini-2.5-flash reads agents/main/agent/models.json ← provider config, baseUrl, api type, compat flags reads agents/main/agent/auth-profiles.json ← no google key here reads ~/.openclaw/.env ← GEMINI_API_KEY (actual key) ↓ OpenClaw Google Plugin (plugins.entries.google) ↓ Builds API request

  • applies thinking=medium ← IGNORES compat flags here (the bug)
  • sends to baseUrl/models/gemini-2.5-flash:generateContent ↓ Google Generative AI API ↓ 400 error (request rejected) ↓ Gateway returns error to Telegram

Logs, screenshots, and evidence

NOT_ENOUGH_INFO

Impact and severity

NOT_ENOUGH_INFO

Additional information

NOT_ENOUGH_INFO

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Connection to Gemma models ideally

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: [Bug]: Google Generative AI API error (400) on ALL Google models — thinking=medium sent despite compat flags [1 pull requests, 1 comments, 2 participants]