Skip to content

fix: handle vscode-lm-proxy model ID for claude provider - #19

Open
leewinn1 wants to merge 1 commit into
ryonakae:mainfrom
leewinn1:main
Open

fix: handle vscode-lm-proxy model ID for claude provider#19
leewinn1 wants to merge 1 commit into
ryonakae:mainfrom
leewinn1:main

Conversation

@leewinn1

Copy link
Copy Markdown

Problem

The Claude Code endpoint (POST /anthropic/claude/v1/messages) fails with a 404 error when using "model": "vscode-lm-proxy" in the request. The error indicates the model is not found in the VSCode Language Model API.

Root Cause

The getVSCodeModel() function in src/server/handler.ts was missing a case to handle provider === 'claude' when modelId === 'vscode-lm-proxy'. This caused the function to pass 'vscode-lm-proxy' directly to vscode.lm.selectChatModels() instead of resolving it to the actual selected Claude Code Background model.

Solution

Added a check in the if (modelId === 'vscode-lm-proxy') condition to handle the Claude provider by resolving to the selected Claude Code Background model, matching the behavior for OpenAI and Anthropic providers.

Changes

  • src/server/handler.ts: Added Claude provider handling in getVSCodeModel() function

Testing

The fix allows the Claude Code endpoint to properly resolve and use the selected Claude model when vscode-lm-proxy is specified as the model name.

When provider is 'claude' and modelId is 'vscode-lm-proxy', properly
resolve to the selected Claude Code Background model instead of
throwing a 'model not found' error.

Fixes issue where Claude Code endpoint failed with 404 when using
vscode-lm-proxy as the model name.
Copilot AI review requested due to automatic review settings January 14, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a 404 error in the Claude Code endpoint by adding proper handling for the 'vscode-lm-proxy' model ID when using the Claude provider. The fix ensures that when vscode-lm-proxy is specified, the function resolves it to the selected Claude Code Background model.

Changes:

  • Added Claude provider case in the vscode-lm-proxy resolution block to map to the Background model
  • Updated the Claude-specific model routing logic to skip when modelId is 'vscode-lm-proxy' (already resolved)
  • Added null-checking for the Background and Thinking model retrieval operations

Comment thread src/server/handler.ts
Comment on lines +51 to +52
} else if (provider === 'claude') {
selectedModelId = modelManager.getClaudeCodeBackgroundModelId()

Copilot AI Jan 14, 2026

Copy link

Choose a reason for hiding this comment

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

The choice to always use Background model for vscode-lm-proxy with Claude provider may not align with all use cases. Consider documenting why Background model is the default choice rather than Thinking model, or consider making this configurable. This is consistent with how OpenAI and Anthropic providers work (they each have a single default), but the Claude provider has two distinct model types (Background vs Thinking).

Copilot uses AI. Check for mistakes.
Comment thread src/server/handler.ts
Comment on lines +63 to +71
const backgroundModel = modelManager.getClaudeCodeBackgroundModelId()
if (backgroundModel) {
selectedModelId = backgroundModel
}
} else if (modelId.includes('sonnet') || modelId.includes('opus')) {
selectedModelId = modelManager.getClaudeCodeThinkingModelId()
const thinkingModel = modelManager.getClaudeCodeThinkingModelId()
if (thinkingModel) {
selectedModelId = thinkingModel
}

Copilot AI Jan 14, 2026

Copy link

Choose a reason for hiding this comment

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

The null-checking added here is good defensive programming. However, if these methods return null, selectedModelId retains its previous value (the original modelId), which will likely fail at line 78-80 when calling vscode.lm.selectChatModels(). Consider throwing an error with a clear message when the required model configuration is missing, rather than silently continuing with an invalid model ID.

Copilot uses AI. Check for mistakes.
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.

2 participants