Skip to content

fix: strip unsupported thinking key for Gemini OpenAI-compatible endpoint (#1515)#2106

Open
asong56 wants to merge 2 commits intobytedance:mainfrom
asong56:1515
Open

fix: strip unsupported thinking key for Gemini OpenAI-compatible endpoint (#1515)#2106
asong56 wants to merge 2 commits intobytedance:mainfrom
asong56:1515

Conversation

@asong56
Copy link
Copy Markdown

@asong56 asong56 commented Apr 10, 2026

Description

Google's official OpenAI-compatible endpoint for Gemini does not support the thinking key inside extra_body, which previously caused a 400 BadRequestError.

This PR introduces a non-destructive helper _strip_unsupported_extra_body in PatchedChatOpenAI to remove this key before sending the request. This ensures compatibility while keeping the configuration useful for other gateways (like Vertex AI) that do support it.

Changes

  • Modified backend/packages/harness/deerflow/models/patched_openai.py
  • Added backend/tests/test_patched_openai_issue1515.py

Checklist

  • All existing tests pass.
  • New unit tests added for stripping logic and mutation safety.

closes #1515

asong56 added 2 commits April 10, 2026 17:29
Fixes issue bytedance#1515 by stripping unsupported 'thinking' key from extra_body in requests to the Google OpenAI-compatible endpoint. Enhances the PatchedChatOpenAI class to preserve thought_signature and prevent HTTP 400 errors.
Added tests to verify the stripping of unsupported keys from extra_body and the restoration of tool call signatures.
@WillemJiang
Copy link
Copy Markdown
Collaborator

@asong56 thanks for your contribution. Did you have a chance to verify the fix with the Gemini API?
BTW, please fix the lint error as well.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini API using Official OpenAI-Compatible Endpoint Fails

2 participants