fix(openrouter): skip empty reasoning block for non-reasoning models#6946
Open
pratikm778 wants to merge 1 commit intoagno-agi:mainfrom
Open
fix(openrouter): skip empty reasoning block for non-reasoning models#6946pratikm778 wants to merge 1 commit intoagno-agi:mainfrom
pratikm778 wants to merge 1 commit intoagno-agi:mainfrom
Conversation
Override _set_reasoning_request_param in OpenRouterResponses to only send
a reasoning block when the caller explicitly configures reasoning params
(reasoning, reasoning_effort, or reasoning_summary). The parent class
unconditionally sends reasoning: {} which causes OpenRouter-hosted models
like Gemini 3.1 Pro Preview to reject the request.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Override
_set_reasoning_request_paraminOpenRouterResponsesto only send areasoningblock when the caller explicitly configures reasoning parameters (reasoning,reasoning_effort, orreasoning_summary). The parent classOpenResponsesunconditionally sendsreasoning: {}, which causes OpenRouter-hosted models like Gemini 3.1 Pro Preview to reject the request.Fixes #6945. Related to #5329.
Type of change
Checklist
./scripts/format.shand./scripts/validate.sh)Additional Notes
What changed:
libs/agno/agno/models/openrouter/responses.py— new_set_reasoning_request_paramoverride that returnsbase_paramsunmodified when no reasoning params are configuredlibs/agno/tests/unit/models/openrouter_model/test_openrouter_responses_reasoning.py— 5 unit tests covering: no reasoning when unconfigured, reasoning sent with effort/summary/dict, and parent class behavior documentationRoot cause:
OpenResponses._set_reasoning_request_param()always setsbase_params["reasoning"] = self.reasoning or {}, meaning every request includesreasoning: {}even for models that don't support it.