Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 27, 2025

This PR implements the feature requested by @LousyBook94 in PR #7452.

Summary

Added a checkbox option to allow users to opt-in to using the full 128k context window for the magistral-medium-latest model, with a warning about potential performance degradation.

Changes

  • ✅ Added useMaximumContextWindow field to provider settings schema
  • ✅ Implemented checkbox UI in Mistral provider settings
  • ✅ Added yellow warning message about performance degradation when enabled
  • ✅ Updated context window logic to limit to 41k tokens when checkbox is unchecked (default)
  • ✅ Added localization strings for the new feature

How it works

  • By default, the checkbox is unchecked and the context window is limited to 41k tokens for better performance
  • When users check the box, they get access to the full 128k context window
  • A yellow warning appears when the checkbox is checked to inform users about potential performance impacts

Testing

  • ✅ All existing tests pass
  • ✅ TypeScript compilation successful
  • ✅ Linting checks pass

Screenshots

The feature adds a checkbox with a warning in the Mistral provider settings when the magistral-medium-latest model is selected.

Fixes the enhancement requested in #7452


Important

Adds a checkbox in Mistral settings to toggle between 41k and 128k context window for magistral-medium-latest model, with schema, UI, and localization updates.

  • Behavior:
    • Adds useMaximumContextWindow field to provider settings schema in provider-settings.ts.
    • Updates getModel() in mistral.ts to limit context window to 41k tokens by default for magistral-medium-latest.
    • Implements checkbox in Mistral.tsx to toggle full 128k context window.
  • UI:
    • Adds checkbox and warning message in Mistral.tsx for magistral-medium-latest model.
    • Updates localization strings in settings.json for new checkbox and warning.
  • Models:
    • Updates mistralModels in providers/mistral.ts to set maxTokens and contextWindow to 128k for magistral-medium-latest.

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

…dium model

- Added useMaximumContextWindow field to provider settings schema
- Implemented checkbox UI in Mistral provider settings with yellow warning
- Updated context window logic to limit to 41k tokens when checkbox is unchecked
- Added localization strings for the new feature

This allows users to opt-in to using the full 128k context window for the magistral-medium-latest model, with a warning about potential performance degradation.
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 27, 2025 13:02
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Aug 27, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code is like debugging in a mirror - everything looks backward but the bugs are still mine.

// Create a modified info object with reduced context window for better performance
info = {
...info,
contextWindow: 41000 as any, // Use reduced context for better performance
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is using as any intentional here? This bypasses TypeScript's type checking and could hide potential type errors. Consider creating a proper type for the modified info object or using a type assertion that's more specific:

Suggested change
contextWindow: 41000 as any, // Use reduced context for better performance
contextWindow: 41000,
maxTokens: 41000,

let info = mistralModels[id as MistralModelId] ?? mistralModels[mistralDefaultModelId]

// For magistral-medium-latest, optionally limit context window if useMaximumContextWindow is false
if (id === "magistral-medium-latest" && !this.options.useMaximumContextWindow && info.contextWindow > 41000) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we extract this magic number (41000) into a named constant like MAGISTRAL_MEDIUM_PERFORMANCE_LIMIT? This would make the code more maintainable and self-documenting.

"magistral-medium-latest": {
maxTokens: 41_000,
contextWindow: 41_000,
maxTokens: 128_000,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I notice we're setting both maxTokens and contextWindow to 128k here, but the getModel() logic in mistral.ts will limit it to 41k by default when useMaximumContextWindow is false. Is this intentional? It might be clearer to keep the default at 41k here and only expand to 128k when the checkbox is enabled.

</Checkbox>
{apiConfiguration?.useMaximumContextWindow && (
<div className="flex items-start gap-2 p-2 rounded-md bg-[color-mix(in_srgb,var(--vscode-editorWarning-foreground)_20%,transparent)] border border-[var(--vscode-editorWarning-foreground)]">
<span className="codicon codicon-warning text-[var(--vscode-editorWarning-foreground)] mt-0.5"></span>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider adding an aria-label to the warning icon for better accessibility:

Suggested change
<span className="codicon codicon-warning text-[var(--vscode-editorWarning-foreground)] mt-0.5"></span>
<span className="codicon codicon-warning text-[var(--vscode-editorWarning-foreground)] mt-0.5" aria-label="Warning"></span>

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 27, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Aug 28, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 28, 2025
@daniel-lxs
Copy link
Member

#7452 (comment)

@daniel-lxs daniel-lxs closed this Sep 1, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 1, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Needs Preliminary Review size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants