From 4e2b89c43cb9c2e574ea309b1dc902713a3da5f2 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 26 May 2026 13:31:53 +0200 Subject: [PATCH 1/4] 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 --- NEXT_CHANGELOG.md | 2 + .../com/databricks/sdk/core/UserAgent.java | 12 ++---- .../databricks/sdk/core/UserAgentTest.java | 41 +++++++++---------- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 4c012ef5e..dc14b5945 100644 --- a/NEXT_CHANGELOG.md +++ b/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. + ### Breaking Changes ### Bug Fixes diff --git a/databricks-sdk-java/src/main/java/com/databricks/sdk/core/UserAgent.java b/databricks-sdk-java/src/main/java/com/databricks/sdk/core/UserAgent.java index c7689853a..a04c68882 100644 --- a/databricks-sdk-java/src/main/java/com/databricks/sdk/core/UserAgent.java +++ b/databricks-sdk-java/src/main/java/com/databricks/sdk/core/UserAgent.java @@ -267,8 +267,6 @@ private static List listKnownAgents() { new KnownAgent("CLINE_ACTIVE", "cline"), // https://github.com/cline/cline (v3.24.0+) new KnownAgent("CODEX_CI", "codex"), // https://github.com/openai/codex new KnownAgent("COPILOT_CLI", "copilot-cli"), // https://github.com/features/copilot - // VS Code Copilot terminal; best-effort heuristic, not officially identified. - new KnownAgent("COPILOT_MODEL", "copilot-vscode"), new KnownAgent("CURSOR_AGENT", "cursor"), // Closed source new KnownAgent("GEMINI_CLI", "gemini-cli"), // https://google-gemini.github.io/gemini-cli new KnownAgent( @@ -277,6 +275,9 @@ private static List listKnownAgents() { new KnownAgent("KIRO", "kiro"), // https://kiro.dev/ (Amazon) new KnownAgent("OPENCLAW_SHELL", "openclaw"), // https://github.com/anthropics/openclaw new KnownAgent("OPENCODE", "opencode"), // https://github.com/opencode-ai/opencode + // Set by VS Code 1.121+ for agent-initiated terminal commands + // (https://code.visualstudio.com/updates/v1_121). + new KnownAgent("VSCODE_AGENT", "vscode-agent"), new KnownAgent("WINDSURF_AGENT", "windsurf")); // https://codeium.com/windsurf (Codeium) } @@ -310,13 +311,6 @@ private static String lookupAgentProvider(Environment env) { } } - // Known BYOK false positive: Copilot CLI users often set COPILOT_MODEL - // alongside COPILOT_CLI. Treat that pair as a single copilot-cli signal - // rather than a stacked multi-agent setup. - if (matches.contains("copilot-cli") && matches.contains("copilot-vscode")) { - matches.removeIf(m -> m.equals("copilot-vscode")); - } - if (matches.size() == 1) { return matches.get(0); } diff --git a/databricks-sdk-java/src/test/java/com/databricks/sdk/core/UserAgentTest.java b/databricks-sdk-java/src/test/java/com/databricks/sdk/core/UserAgentTest.java index 232409c84..ef8add80c 100644 --- a/databricks-sdk-java/src/test/java/com/databricks/sdk/core/UserAgentTest.java +++ b/databricks-sdk-java/src/test/java/com/databricks/sdk/core/UserAgentTest.java @@ -241,14 +241,27 @@ public void testAgentProviderAugment() { } @Test - public void testAgentProviderCopilotVscode() { + public void testAgentProviderVscodeAgent() { + setupAgentEnv( + new HashMap() { + { + put("VSCODE_AGENT", "1"); + } + }); + Assertions.assertTrue(UserAgent.asString().contains("agent/vscode-agent")); + } + + @Test + public void testAgentProviderCopilotModelAloneNotDetected() { + // COPILOT_MODEL is set by Copilot CLI BYOK users and does not by itself + // identify any agent. setupAgentEnv( new HashMap() { { put("COPILOT_MODEL", "gpt-4"); } }); - Assertions.assertTrue(UserAgent.asString().contains("agent/copilot-vscode")); + Assertions.assertFalse(UserAgent.asString().contains("agent/")); } @Test @@ -415,30 +428,14 @@ public void testAgentProviderExplicitEnvWinsOverKnownAgentEnv() { } @Test - public void testAgentProviderCopilotCliAndCopilotVscodeCollapseToCopilotCli() { - // Copilot CLI users (BYOK mode) often set COPILOT_MODEL alongside - // COPILOT_CLI. Treat the pair as a single copilot-cli signal rather - // than a stacked multi-agent setup. - setupAgentEnv( - new HashMap() { - { - put("COPILOT_CLI", "1"); - put("COPILOT_MODEL", "gpt-4"); - } - }); - Assertions.assertTrue(UserAgent.asString().contains("agent/copilot-cli")); - } - - @Test - public void testAgentProviderCopilotByokCollapseStillMultiple() { - // The Copilot BYOK collapse only drops the copilot-vscode match. If - // another agent is also present, the result is still "multiple". + public void testAgentProviderVscodeAgentAndCopilotCliReportsMultiple() { + // VSCODE_AGENT can legitimately stack with other agents (e.g. running + // Copilot CLI from a VS Code agent terminal). setupAgentEnv( new HashMap() { { + put("VSCODE_AGENT", "1"); put("COPILOT_CLI", "1"); - put("COPILOT_MODEL", "gpt-4"); - put("CLAUDECODE", "1"); } }); Assertions.assertTrue(UserAgent.asString().contains("agent/multiple")); From 6fee7bc822f8321ec0df2a4a7a67524e0fee7ac4 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 26 May 2026 13:39:52 +0200 Subject: [PATCH 2/4] Drop the residual COPILOT_MODEL test case --- .../java/com/databricks/sdk/core/UserAgentTest.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/databricks-sdk-java/src/test/java/com/databricks/sdk/core/UserAgentTest.java b/databricks-sdk-java/src/test/java/com/databricks/sdk/core/UserAgentTest.java index ef8add80c..0631a52f0 100644 --- a/databricks-sdk-java/src/test/java/com/databricks/sdk/core/UserAgentTest.java +++ b/databricks-sdk-java/src/test/java/com/databricks/sdk/core/UserAgentTest.java @@ -251,19 +251,6 @@ public void testAgentProviderVscodeAgent() { Assertions.assertTrue(UserAgent.asString().contains("agent/vscode-agent")); } - @Test - public void testAgentProviderCopilotModelAloneNotDetected() { - // COPILOT_MODEL is set by Copilot CLI BYOK users and does not by itself - // identify any agent. - setupAgentEnv( - new HashMap() { - { - put("COPILOT_MODEL", "gpt-4"); - } - }); - Assertions.assertFalse(UserAgent.asString().contains("agent/")); - } - @Test public void testAgentProviderGoose() { setupAgentEnv( From 0cf5cd06e3a60eff43707d013f017767411bfb3c Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 26 May 2026 13:51:01 +0200 Subject: [PATCH 3/4] Drop NEXT_CHANGELOG entry (NO_CHANGELOG=true) --- NEXT_CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index dc14b5945..4c012ef5e 100644 --- a/NEXT_CHANGELOG.md +++ b/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. - ### Breaking Changes ### Bug Fixes From b0dbbdfce8bbbca5737f4d4904ac2a508265118a Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 27 May 2026 09:54:47 +0200 Subject: [PATCH 4/4] chore: empty commit to trigger CI Co-authored-by: Isaac