Skip to content

Detect VS Code agent via VSCODE_AGENT, remove COPILOT_MODEL heuristic#152

Merged
simonfaltum merged 4 commits into
mainfrom
simonfaltum/vscode-agent
May 26, 2026
Merged

Detect VS Code agent via VSCODE_AGENT, remove COPILOT_MODEL heuristic#152
simonfaltum merged 4 commits into
mainfrom
simonfaltum/vscode-agent

Conversation

@simonfaltum

@simonfaltum simonfaltum commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

VS Code 1.121 introduced the VSCODE_AGENT environment variable, set for any agent-initiated terminal command. Detect it as agent/vscode-agent in the user-agent header and remove the unreliable COPILOT_MODEL heuristic that previously reported copilot-vscode.

Why

COPILOT_MODEL is 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 (drop copilot-vscode whenever COPILOT_CLI was also set). Over the last 13 weeks the heuristic identified 3 users / 52 events; copilot-cli saw 539 users / 175k events. The signal was effectively dead. VS Code 1.121's official VSCODE_AGENT signal is reliable and removes the need for the workaround.

What changed

  • packages/core/src/clientinfo/agent.ts: Add VSCODE_AGENT to KNOWN_AGENTS. Remove COPILOT_MODEL entry and the BYOK collapse branch in lookupAgentProvider.
  • packages/core/tests/clientinfo/agent.test.ts: New vscode-agent case and VSCODE_AGENT + COPILOT_CLI stacking test. Removed the BYOK collapse test cases.

VSCODE_AGENT can legitimately stack with COPILOT_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.ts passes (30 tests).
  • npm run format --workspace=packages/core clean.

This PR mirrors parallel changes in databricks-sdk-go, databricks-sdk-py, and databricks-sdk-java.

NO_CHANGELOG=true

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
Comment thread packages/core/NEXT_CHANGELOG.md Outdated
@simonfaltum simonfaltum added this pull request to the merge queue May 26, 2026
Merged via the queue into main with commit 85deb35 May 26, 2026
23 checks passed
@simonfaltum simonfaltum deleted the simonfaltum/vscode-agent branch May 26, 2026 21:07
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