Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Nov 3, 2025

This PR attempts to address Issue #8991. Feedback and guidance are welcome.

Problem

All models in VS Code LM API return a 400 error "Model is not supported for this request" when users try to use them.

Root Cause

The VS Code Language Model API requires exact model IDs for selection, but the implementation was using vendor/family pairs instead.

Solution

  • Updated UI component to store and use model.id instead of vendor/family
  • Modified VsCodeLmHandler to select models by ID when available
  • Added fallback mechanism (ID → selector → default model)
  • Improved error messages to guide users when model approval is needed

Changes

  • UI: Updated dropdown to use model.id as value
  • Handler: Added ID-based model selection with proper fallback
  • Error Handling: Added specific messages for model approval failures
  • Tests: Added coverage for ID-based model selection

Testing

  • All tests pass (unit tests for both UI and handler)
  • Type checking passes
  • Linting passes

Fixes #8991


Important

Fixes VS Code LM API model selection by using model IDs, updates UI and error handling, and adds tests.

  • Behavior:
    • Fixes model selection in VsCodeLmHandler by using model.id instead of vendor/family pairs.
    • Adds fallback mechanism for model selection (ID → selector → default model).
    • Improves error messages for model approval in vscode-lm.ts.
  • UI:
    • Updates dropdown in VSCodeLM.tsx to use model.id as value.
  • Tests:
    • Adds test for ID-based model selection in vscode-lm.spec.ts.
  • Misc:
    • Updates getVsCodeLmModels to filter and map models correctly in vscode-lm.ts.

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

- Updated UI to use model.id instead of vendor/family for model selection
- Modified VsCodeLmHandler to select models by ID when available
- Added proper error handling for model approval failures
- Improved error messages for better user experience
- Added test coverage for ID-based model selection

Fixes #8991
@roomote roomote bot requested review from cte, jr and mrubens as code owners November 3, 2025 04:56
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Nov 3, 2025
@roomote
Copy link
Author

roomote bot commented Nov 3, 2025

See this task on Roo Code Cloud

Review completed. Found 1 issue that should be addressed.

  • Fallback logic in createClient doesn't work correctly when model ID is not found (lines 126-133 in vscode-lm.ts)

Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 3, 2025
Comment on lines +126 to 133
console.warn(
`Roo Code <Language Model API>: Model with ID '${selector.id}' not found, falling back to selector`,
)
}
}

// Fallback to selector-based selection
const models = await vscode.lm.selectChatModels(selector)
Copy link
Author

Choose a reason for hiding this comment

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

The fallback logic here doesn't work as intended. When a model with the specified ID is not found in allModels, the code attempts to fall back by calling selectChatModels(selector), but selector still contains the unfound ID. This means the fallback will return an empty array (since we already confirmed the ID doesn't exist), making the fallback ineffective. To fix this, create a new selector without the ID for the fallback: const { id, ...fallbackSelector } = selector and then use selectChatModels(fallbackSelector) to search by vendor/family only.

@daniel-lxs daniel-lxs closed this Nov 3, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 3, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Nov 3, 2025
@daniel-lxs daniel-lxs deleted the fix/vscode-lm-model-selection-issue-8991 branch November 3, 2025 19:35
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: Done

Development

Successfully merging this pull request may close these issues.

[BUG] API Provider "VS Code LM API" is getting a "Request Failed: 400" for all Language Model

5 participants