Skip to content

Conversation

roomote[bot]
Copy link

@roomote roomote bot commented Oct 17, 2025

Summary

This PR attempts to address Issue #8709 where the grok-4-fast model on OpenRouter was incorrectly showing reasoning effort options (low/medium/high) instead of a simple on/off toggle.

Problem

The grok-4-fast model on OpenRouter currently displays "reasoning effort" options, but according to the OpenRouter documentation, this model should only have reasoning either enabled or disabled (on/off toggle).

Solution

  • Added special handling for model in the OpenRouter parser
  • Disabled for this model while ensuring "reasoning" parameter remains available
  • Updated reasoning transformation logic to handle models with simple on/off toggle using the parameter
  • Added comprehensive tests to verify the functionality

Changes

  • : Added special case for grok-4-fast model
  • : Added logic to handle simple on/off reasoning toggle
  • : Added tests for grok-4-fast handling
  • : Added tests for simple toggle reasoning

Testing

All tests pass successfully:

  • OpenRouter fetcher tests verify correct model configuration
  • Reasoning transformation tests verify correct parameter generation
  • No existing functionality was broken

Fixes #8709

Feedback and guidance are welcome!


Important

Add simple on/off reasoning toggle for grok-4-fast model on OpenRouter, updating parseOpenRouterModel and getOpenRouterReasoning with tests.

  • Behavior:
    • parseOpenRouterModel in openrouter.ts now handles grok-4-fast with a simple on/off reasoning toggle, disabling reasoning effort.
    • getOpenRouterReasoning in reasoning.ts supports models with simple on/off toggle, using exclude parameter.
  • Testing:
    • Added tests in openrouter.spec.ts for grok-4-fast reasoning toggle behavior.
    • Added tests in reasoning.spec.ts for models with simple on/off toggle and ensuring no impact on models with effort or budget capabilities.

This description was created by Ellipsis for 22e9b98. You can customize this summary. It will automatically update as commits are pushed.

…uter

- Added special handling for x-ai/grok-4-fast model in OpenRouter parser
- Disabled reasoning effort for this model while keeping reasoning parameter
- Updated reasoning logic to handle models with simple on/off toggle
- Added comprehensive tests for the new functionality

Fixes #8709
@roomote roomote bot requested review from cte, jr and mrubens as code owners October 17, 2025 19:09
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 17, 2025
Copy link
Author

roomote bot commented Oct 17, 2025

Code Review Summary

I've reviewed the changes and identified 2 issues that need to be addressed:

  • Reasoning toggle doesn't respect enableReasoningEffort setting: The simple toggle logic in src/api/transform/reasoning.ts (lines 44-57) doesn't check if settings.enableReasoningEffort === false. When users explicitly disable reasoning in settings, it should return undefined instead of enabling reasoning.

  • Incorrect default behavior when effort is undefined: When both reasoningEffort and settings.reasoningEffort are undefined, the code defaults to enabling reasoning ({ exclude: false }). This is inconsistent with how other reasoning models work. It should return undefined when no effort preference is set, allowing the API to use its default behavior.

These issues affect the correctness of the reasoning toggle implementation. Please address them before merging.

@dosubot dosubot bot added the bug Something isn't working label Oct 17, 2025
Comment on lines +44 to +57
// Check if model supports reasoning but not effort or budget (e.g., grok-4-fast on OpenRouter)
// These models use a simple on/off toggle via the exclude parameter
if (
model.supportedParameters?.includes("reasoning") &&
!model.supportsReasoningEffort &&
!model.supportsReasoningBudget
) {
// If reasoning is not explicitly disabled, enable it
// We use exclude: false to enable reasoning, and exclude: true to disable
// Check both settings.reasoningEffort and the passed reasoningEffort parameter
const effectiveEffort = reasoningEffort || settings.reasoningEffort
const reasoningEnabled = effectiveEffort !== "minimal"
return reasoningEnabled ? { exclude: false } : { exclude: true }
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simple toggle logic doesn't respect the settings.enableReasoningEffort === false setting. When users explicitly disable reasoning effort in settings, the model should not use reasoning, but this code will still enable it based on the effort values. This should check settings?.enableReasoningEffort === false and return undefined if true, similar to how shouldUseReasoningEffort handles this in src/shared/api.ts lines 66-69.

// Check both settings.reasoningEffort and the passed reasoningEffort parameter
const effectiveEffort = reasoningEffort || settings.reasoningEffort
const reasoningEnabled = effectiveEffort !== "minimal"
return reasoningEnabled ? { exclude: false } : { exclude: true }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When both reasoningEffort and settings.reasoningEffort are undefined, this code enables reasoning by default ({ exclude: false }). This is inconsistent with how other reasoning models work, where undefined effort typically results in no reasoning parameters being sent. For grok-4-fast, when no effort preference is set, it should return undefined instead of defaulting to enabled. This ensures the API's default behavior is respected.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Support disabling reasoning in grok-4-fast on OpenRouter.

2 participants