Skip to content

fix(openrouter): skip empty reasoning block for non-reasoning models#6946

Open
pratikm778 wants to merge 1 commit intoagno-agi:mainfrom
pratikm778:fix/openrouter-skip-empty-reasoning
Open

fix(openrouter): skip empty reasoning block for non-reasoning models#6946
pratikm778 wants to merge 1 commit intoagno-agi:mainfrom
pratikm778:fix/openrouter-skip-empty-reasoning

Conversation

@pratikm778
Copy link

Summary

Override _set_reasoning_request_param in OpenRouterResponses to only send a reasoning block when the caller explicitly configures reasoning parameters (reasoning, reasoning_effort, or reasoning_summary). The parent class OpenResponses unconditionally sends reasoning: {}, which causes OpenRouter-hosted models like Gemini 3.1 Pro Preview to reject the request.

Fixes #6945. Related to #5329.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable)
  • Tested in clean environment
  • Tests added/updated (if applicable)

Additional Notes

What changed:

  • libs/agno/agno/models/openrouter/responses.py — new _set_reasoning_request_param override that returns base_params unmodified when no reasoning params are configured
  • libs/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 documentation

Root cause: OpenResponses._set_reasoning_request_param() always sets base_params["reasoning"] = self.reasoning or {}, meaning every request includes reasoning: {} even for models that don't support it.

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>
@pratikm778 pratikm778 requested a review from a team as a code owner March 10, 2026 17:49
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.

[Bug] OpenRouterResponses sends empty reasoning block to non-reasoning models

1 participant