Skip to content

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

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

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

Conversation

@simonfaltum
Copy link
Copy Markdown
Member

@simonfaltum simonfaltum commented May 26, 2026

Why

VS Code 1.121 introduced the VSCODE_AGENT environment variable, set for any agent-initiated terminal command (Copilot Chat agent mode and other agent extensions). This is the official signal for VS Code agent usage.

The previous heuristic detected COPILOT_MODEL and reported copilot-vscode, but COPILOT_MODEL is actually set by Copilot CLI users who bring their own key, not specifically by VS Code. This 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.

Changes

  • Add VSCODE_AGENT to listKnownAgents(), reported as agent/vscode-agent.
  • Remove the COPILOT_MODEL to copilot-vscode mapping.
  • Remove the BYOK collapse logic. 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.

Tests

  • Updated UserAgentTest.java: new testAgentProviderVscodeAgent and stacking test.
  • mvn test -Dtest=UserAgentTest passes (40 tests, 0 failures).
  • make fmt clean.

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

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
@simonfaltum simonfaltum requested a review from hectorcast-db May 26, 2026 11:41
Co-authored-by: Isaac
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 27, 2026 07:55 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-java

Inputs:

  • PR number: 810
  • Commit SHA: b0dbbdfce8bbbca5737f4d4904ac2a508265118a

Checks will be approved automatically on success.

@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 27, 2026 07:55 — with GitHub Actions Inactive
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 27, 2026 15:39 — with GitHub Actions Inactive
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 27, 2026 15:40 — with GitHub Actions Inactive
@simonfaltum simonfaltum added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit a2ea56c May 27, 2026
20 checks passed
@simonfaltum simonfaltum deleted the simonfaltum/vscode-agent branch May 27, 2026 15:52
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