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
chrisst pushed a commit to chrisst/databricks-sdk-py that referenced this pull request Jun 12, 2026
…databricks#1444)

## Why

[VS Code 1.121](https://code.visualstudio.com/updates/v1_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 `_KNOWN_AGENTS`, 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

- [x] Updated `tests/test_user_agent.py`: new `vscode-agent` case,
`VSCODE_AGENT + COPILOT_CLI` stacks to `multiple`.
- [x] `pytest tests/test_user_agent.py` passes (42 tests).
- [x] `make fmt` clean.

This PR mirrors parallel changes in
[databricks-sdk-go](databricks/databricks-sdk-go#1697),
[databricks-sdk-java](databricks/databricks-sdk-java#810),
and [sdk-js](databricks/sdk-js#152).

NO_CHANGELOG=true
alexott pushed a commit to alexott/databricks-sdk-go that referenced this pull request Jun 17, 2026
…databricks#1697)

## Why

[VS Code 1.121](https://code.visualstudio.com/updates/v1_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 the known agents list, reported as
`agent/vscode-agent`.
- Remove the `COPILOT_MODEL` to `copilot-vscode` mapping.
- Remove the `collapseCopilotBYOK` function. `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

- [x] Updated `agent_test.go`: new `vscode-agent` case, `VSCODE_AGENT +
COPILOT_CLI` stacks to `multiple`.
- [x] `make test` passes.
- [x] `make fmt lint` clean.

This PR mirrors parallel changes in
[databricks-sdk-py](databricks/databricks-sdk-py#1444),
[databricks-sdk-java](databricks/databricks-sdk-java#810),
and [sdk-js](databricks/sdk-js#152).

NO_CHANGELOG=true

---------

Signed-off-by: simon <simon.faltum@databricks.com>
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