Detect VS Code agent via VSCODE_AGENT, remove COPILOT_MODEL heuristic#152
Merged
Conversation
VS Code 1.121+ sets VSCODE_AGENT for agent-initiated terminal commands. Detect it as `vscode-agent` in the User-Agent header. The previous COPILOT_MODEL heuristic reported `copilot-vscode` but COPILOT_MODEL is set by Copilot CLI BYOK users, not specifically by VS Code. The BYOK collapse logic (drop copilot-vscode when COPILOT_CLI is also set) is removed alongside the heuristic; VSCODE_AGENT can legitimately stack with COPILOT_CLI, which now correctly reports `multiple`. See: https://code.visualstudio.com/updates/v1_121
parthban-db
approved these changes
May 26, 2026
This was referenced May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VS Code 1.121 introduced the
VSCODE_AGENTenvironment variable, set for any agent-initiated terminal command. Detect it asagent/vscode-agentin the user-agent header and remove the unreliableCOPILOT_MODELheuristic that previously reportedcopilot-vscode.Why
COPILOT_MODELis set by Copilot CLI users who bring their own key, not specifically by VS Code. The previous mapping produced false positives and required a BYOK collapse workaround (dropcopilot-vscodewheneverCOPILOT_CLIwas also set). Over the last 13 weeks the heuristic identified 3 users / 52 events;copilot-clisaw 539 users / 175k events. The signal was effectively dead. VS Code 1.121's officialVSCODE_AGENTsignal is reliable and removes the need for the workaround.What changed
packages/core/src/clientinfo/agent.ts: AddVSCODE_AGENTtoKNOWN_AGENTS. RemoveCOPILOT_MODELentry and the BYOK collapse branch inlookupAgentProvider.packages/core/tests/clientinfo/agent.test.ts: Newvscode-agentcase andVSCODE_AGENT + COPILOT_CLIstacking test. Removed the BYOK collapse test cases.VSCODE_AGENTcan legitimately stack withCOPILOT_CLI(e.g. running Copilot CLI from a VS Code agent terminal), so the multi-agent path covers it without special handling.Test plan
npx vitest run packages/core/tests/clientinfo/agent.test.tspasses (30 tests).npm run format --workspace=packages/coreclean.This PR mirrors parallel changes in databricks-sdk-go, databricks-sdk-py, and databricks-sdk-java.
NO_CHANGELOG=true