From 028b00d1e9473b6f0dd20423df4d354f646dee6d Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 26 May 2026 13:31:57 +0200 Subject: [PATCH 1/3] Detect VS Code agent via VSCODE_AGENT, remove COPILOT_MODEL heuristic 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 --- packages/core/NEXT_CHANGELOG.md | 2 ++ packages/core/src/clientinfo/agent.ts | 14 ++++---------- packages/core/tests/clientinfo/agent.test.ts | 18 +++++++++--------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/packages/core/NEXT_CHANGELOG.md b/packages/core/NEXT_CHANGELOG.md index a44d8a902..9ec8b87e8 100644 --- a/packages/core/NEXT_CHANGELOG.md +++ b/packages/core/NEXT_CHANGELOG.md @@ -4,6 +4,8 @@ ### New Features and Improvements +* Detect VS Code agent-initiated terminal commands via the `VSCODE_AGENT` environment variable (VS Code 1.121+). The User-Agent header now reports `agent/vscode-agent` when set. The previous `COPILOT_MODEL` heuristic (which reported `agent/copilot-vscode`) has been removed; it produced false positives for Copilot CLI BYOK users and never reliably identified VS Code. + ### Bug Fixes ### Documentation diff --git a/packages/core/src/clientinfo/agent.ts b/packages/core/src/clientinfo/agent.ts index 0b43af7fc..2ea806eaa 100644 --- a/packages/core/src/clientinfo/agent.ts +++ b/packages/core/src/clientinfo/agent.ts @@ -31,9 +31,6 @@ const KNOWN_AGENTS: readonly KnownAgent[] = [ {envVar: 'CLINE_ACTIVE', product: 'cline'}, {envVar: 'CODEX_CI', product: 'codex'}, {envVar: 'COPILOT_CLI', product: 'copilot-cli'}, - // VS Code Copilot terminal, best-effort heuristic, not officially - // identified. - {envVar: 'COPILOT_MODEL', product: 'copilot-vscode'}, {envVar: 'CURSOR_AGENT', product: 'cursor'}, {envVar: 'GEMINI_CLI', product: 'gemini-cli'}, // The goose agent also sets AGENT=goose, handled by the central @@ -42,6 +39,9 @@ const KNOWN_AGENTS: readonly KnownAgent[] = [ {envVar: 'KIRO', product: 'kiro'}, {envVar: 'OPENCLAW_SHELL', product: 'openclaw'}, {envVar: 'OPENCODE', product: 'opencode'}, + // Set by VS Code 1.121+ for agent-initiated terminal commands + // (https://code.visualstudio.com/updates/v1_121). + {envVar: 'VSCODE_AGENT', product: 'vscode-agent'}, {envVar: 'WINDSURF_AGENT', product: 'windsurf'}, ]; @@ -78,18 +78,12 @@ function agentEnvFallback(): string { * - `""` when nothing is set. */ export function lookupAgentProvider(): string { - let matches: string[] = []; + const matches: string[] = []; for (const a of KNOWN_AGENTS) { if (a.envVar in process.env) { matches.push(a.product); } } - // Known BYOK false positive: Copilot CLI users often set COPILOT_MODEL - // alongside COPILOT_CLI. Treat the pair as a single copilot-cli signal - // rather than a stacked multi-agent setup. - if (matches.includes('copilot-cli') && matches.includes('copilot-vscode')) { - matches = matches.filter(m => m !== 'copilot-vscode'); - } if (matches.length === 1) { return matches[0]; } diff --git a/packages/core/tests/clientinfo/agent.test.ts b/packages/core/tests/clientinfo/agent.test.ts index ec6ef93ce..525d635c1 100644 --- a/packages/core/tests/clientinfo/agent.test.ts +++ b/packages/core/tests/clientinfo/agent.test.ts @@ -65,9 +65,14 @@ describe('lookupAgentProvider', () => { want: 'copilot-cli', }, { - name: 'copilot vscode', + name: 'vscode-agent', + env: {VSCODE_AGENT: '1'}, + want: 'vscode-agent', + }, + { + name: 'COPILOT_MODEL alone is no longer detected', env: {COPILOT_MODEL: 'gpt-4'}, - want: 'copilot-vscode', + want: '', }, { name: 'cursor', @@ -165,13 +170,8 @@ describe('lookupAgentProvider', () => { want: 'claude-code', }, { - name: 'COPILOT_CLI + COPILOT_MODEL collapses to copilot-cli (BYOK)', - env: {COPILOT_CLI: '1', COPILOT_MODEL: 'gpt-4'}, - want: 'copilot-cli', - }, - { - name: 'COPILOT_CLI + COPILOT_MODEL + CLAUDECODE still reports multiple after BYOK collapse', - env: {COPILOT_CLI: '1', COPILOT_MODEL: 'gpt-4', CLAUDECODE: '1'}, + name: 'VSCODE_AGENT + COPILOT_CLI reports multiple', + env: {VSCODE_AGENT: '1', COPILOT_CLI: '1'}, want: 'multiple', }, ]; From 48c4f4024dfedd645eb96de84d221530baca2578 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 26 May 2026 13:39:54 +0200 Subject: [PATCH 2/3] Drop the residual COPILOT_MODEL test case --- packages/core/tests/clientinfo/agent.test.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/core/tests/clientinfo/agent.test.ts b/packages/core/tests/clientinfo/agent.test.ts index 525d635c1..967caa067 100644 --- a/packages/core/tests/clientinfo/agent.test.ts +++ b/packages/core/tests/clientinfo/agent.test.ts @@ -69,11 +69,6 @@ describe('lookupAgentProvider', () => { env: {VSCODE_AGENT: '1'}, want: 'vscode-agent', }, - { - name: 'COPILOT_MODEL alone is no longer detected', - env: {COPILOT_MODEL: 'gpt-4'}, - want: '', - }, { name: 'cursor', env: {CURSOR_AGENT: '1'}, From 35d18c1ee14503ac786139342d06c7249c88964a Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 26 May 2026 13:51:03 +0200 Subject: [PATCH 3/3] Drop NEXT_CHANGELOG entry (NO_CHANGELOG=true) --- packages/core/NEXT_CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/core/NEXT_CHANGELOG.md b/packages/core/NEXT_CHANGELOG.md index 9ec8b87e8..a44d8a902 100644 --- a/packages/core/NEXT_CHANGELOG.md +++ b/packages/core/NEXT_CHANGELOG.md @@ -4,8 +4,6 @@ ### New Features and Improvements -* Detect VS Code agent-initiated terminal commands via the `VSCODE_AGENT` environment variable (VS Code 1.121+). The User-Agent header now reports `agent/vscode-agent` when set. The previous `COPILOT_MODEL` heuristic (which reported `agent/copilot-vscode`) has been removed; it produced false positives for Copilot CLI BYOK users and never reliably identified VS Code. - ### Bug Fixes ### Documentation