Skip to content

fix(core): sanitize reasoning parameter for openrouter - #1222

Open
vicpara wants to merge 2 commits into
musistudio:mainfrom
vicpara:main
Open

vicpara wants to merge 2 commits into
musistudio:mainfrom
vicpara:main

Conversation

@vicpara

@vicpara vicpara commented Feb 20, 2026

Copy link
Copy Markdown

Description

This PR fixes an issue where OpenRouter would reject requests for models that require reasoning (like google/gemini-3.1-pro-preview) when the reasoning parameter was explicitly disabled.

The Issue

When Claude Code sends a request with thinking disabled, the router translates this to reasoning: { enabled: false }. However, OpenRouter's API does not support the enabled field. Furthermore, for models that mandate reasoning, explicitly passing a disabled state causes a 400 Bad Request error.

The Fix

This PR updates OpenrouterTransformer.transformRequestIn to properly sanitize the reasoning parameter:

  • If reasoning.enabled is false, the reasoning object is deleted entirely. This allows OpenRouter to fall back to the model's default behavior.
  • If reasoning.enabled is true, the enabled property is removed so that only the effort parameter (which OpenRouter expects) is passed along.

This branch has not been deployed

No deployments
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.

1 participant