fix: strip unsupported thinking key for Gemini OpenAI-compatible endpoint (#1515)#2106
Open
asong56 wants to merge 2 commits intobytedance:mainfrom
Open
fix: strip unsupported thinking key for Gemini OpenAI-compatible endpoint (#1515)#2106asong56 wants to merge 2 commits intobytedance:mainfrom
asong56 wants to merge 2 commits intobytedance:mainfrom
Conversation
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.
Collaborator
|
@asong56 thanks for your contribution. Did you have a chance to verify the fix with the Gemini API? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Google's official OpenAI-compatible endpoint for Gemini does not support the
thinkingkey insideextra_body, which previously caused a400 BadRequestError.This PR introduces a non-destructive helper
_strip_unsupported_extra_bodyinPatchedChatOpenAIto 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
backend/packages/harness/deerflow/models/patched_openai.pybackend/tests/test_patched_openai_issue1515.pyChecklist
closes #1515