feat(vscode-lm): add Copilot modelOptions for agent request classification#11291
feat(vscode-lm): add Copilot modelOptions for agent request classification#11291roomote[bot] wants to merge 1 commit intomainfrom
Conversation
…ation When the VS Code LM model vendor is "copilot", attach modelOptions with copilot-integration-id to sendRequest calls. This allows the Copilot backend to distinguish agent-initiated requests from direct user chat, which may help with proper billing classification of premium vs non-premium requests. Requires VS Code >= 1.96 where modelOptions became stable; older versions silently ignore the extra property. Refs: #11289
Clean PR. One minor nit flagged:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| const requestOptions: vscode.LanguageModelChatRequestOptions = { | ||
| justification: `Roo Code would like to use '${client.name}' from '${client.vendor}', Click 'Allow' to proceed.`, | ||
| tools: convertToVsCodeLmTools(metadata?.tools ?? []), | ||
| } | ||
| ...(isCopilotModel(client) ? { modelOptions: buildCopilotModelOptions() } : {}), | ||
| } as vscode.LanguageModelChatRequestOptions |
There was a problem hiding this comment.
[nit] The as vscode.LanguageModelChatRequestOptions assertion is unnecessary here (and at line 610 in completePrompt). The resolved @types/vscode@1.100.0 already includes modelOptions in LanguageModelChatRequestOptions, so the object literal is assignable without a cast. In createMessage the variable already carries the same type annotation on the left-hand side, making the assertion doubly redundant. Dropping the as casts lets TypeScript catch property-name typos in the object literal.
| const requestOptions: vscode.LanguageModelChatRequestOptions = { | |
| justification: `Roo Code would like to use '${client.name}' from '${client.vendor}', Click 'Allow' to proceed.`, | |
| tools: convertToVsCodeLmTools(metadata?.tools ?? []), | |
| } | |
| ...(isCopilotModel(client) ? { modelOptions: buildCopilotModelOptions() } : {}), | |
| } as vscode.LanguageModelChatRequestOptions | |
| const requestOptions: vscode.LanguageModelChatRequestOptions = { | |
| justification: `Roo Code would like to use '${client.name}' from '${client.vendor}', Click 'Allow' to proceed.`, | |
| tools: convertToVsCodeLmTools(metadata?.tools ?? []), | |
| ...(isCopilotModel(client) ? { modelOptions: buildCopilotModelOptions() } : {}), | |
| } |
Fix it with Roo Code or mention @roomote and request a fix.
Related GitHub Issue
Closes: #11289
Description
This PR attempts to address Issue #11289 by enhancing the existing VS Code LM provider to pass
modelOptionswhen the model vendor is GitHub Copilot ("copilot").What changed:
"copilot"), it now attachesmodelOptionswithcopilot-integration-id: "roo-code"to everysendRequestcall (bothcreateMessageandcompletePrompt).modelOptionsproperty onLanguageModelChatRequestOptions(stable since VS Code 1.96). On older VS Code versions, the extra property is silently ignored.isCopilotModel(),buildCopilotModelOptions(), and theCOPILOT_VENDORconstant.Design choices / trade-offs:
copilot-integration-idheader value is based on the pattern referenced in the copilot-api project. The exact model options that the Copilot backend uses for billing classification may need further refinement based on feedback from users and the Copilot team."copilot"-- no new user-facing settings are required.as vscode.LanguageModelChatRequestOptions) is used becausemodelOptionswas added in @types/vscode 1.96 while the project targets ^1.84.0.Feedback and guidance are welcome.
Test Procedure
vscode-lm.spec.ts:should include modelOptions when model vendor is copilot(createMessage)should NOT include modelOptions when model vendor is not copilot(createMessage)should include modelOptions in completePrompt when model vendor is copilotshould NOT include modelOptions in completePrompt when model vendor is not copilotcd src && npx vitest run api/providers/__tests__/vscode-lm.spec.tsPre-Submission Checklist
Screenshots / Videos
N/A -- no UI changes.
Documentation Updates
Additional Notes
This is a first step toward better Copilot billing integration. The
modelOptionsvalues may need to be adjusted based on what the Copilot backend actually expects for proper agent request classification. Community testing with active Copilot subscriptions would be very helpful to validate the billing impact.Important
Add
modelOptionsfor GitHub Copilot requests in VS Code LM API to aid billing classification.modelOptionswithcopilot-integration-id: "roo-code"tosendRequestcalls increateMessageandcompletePromptwhen vendor is"copilot".modelOptionsproperty onLanguageModelChatRequestOptions(requires VS Code >= 1.96).isCopilotModel()to check if model vendor is Copilot.buildCopilotModelOptions()to construct model options for Copilot.vscode-lm.spec.tsto verifymodelOptionsinclusion/exclusion based on vendor.COPILOT_VENDORconstant for vendor string comparison.This description was created by
for cc0c716. You can customize this summary. It will automatically update as commits are pushed.