Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ private static List<KnownAgent> 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(
Expand All @@ -277,6 +275,9 @@ private static List<KnownAgent> 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)
}

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ public void testAgentProviderAugment() {
}

@Test
public void testAgentProviderCopilotVscode() {
public void testAgentProviderVscodeAgent() {
setupAgentEnv(
new HashMap<String, String>() {
{
put("COPILOT_MODEL", "gpt-4");
put("VSCODE_AGENT", "1");
}
});
Assertions.assertTrue(UserAgent.asString().contains("agent/copilot-vscode"));
Assertions.assertTrue(UserAgent.asString().contains("agent/vscode-agent"));
}

@Test
Expand Down Expand Up @@ -415,30 +415,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.
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<String, String>() {
{
put("VSCODE_AGENT", "1");
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".
setupAgentEnv(
new HashMap<String, String>() {
{
put("COPILOT_CLI", "1");
put("COPILOT_MODEL", "gpt-4");
put("CLAUDECODE", "1");
}
});
Assertions.assertTrue(UserAgent.asString().contains("agent/multiple"));
Expand Down
Loading