Skip to content
Merged
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
14 changes: 4 additions & 10 deletions packages/core/src/clientinfo/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'},
];

Expand Down Expand Up @@ -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];
}
Expand Down
15 changes: 5 additions & 10 deletions packages/core/tests/clientinfo/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ describe('lookupAgentProvider', () => {
want: 'copilot-cli',
},
{
name: 'copilot vscode',
env: {COPILOT_MODEL: 'gpt-4'},
want: 'copilot-vscode',
name: 'vscode-agent',
env: {VSCODE_AGENT: '1'},
want: 'vscode-agent',
},
{
name: 'cursor',
Expand Down Expand Up @@ -165,13 +165,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',
},
];
Expand Down
Loading