Detect additional third-party coding agents by BagToad · Pull Request #13722 · cli/cli · GitHub
Skip to content

Detect additional third-party coding agents#13722

Merged
BagToad merged 5 commits into
cli:trunkfrom
BagToad:bagtoad/extend-3p-agent-detection
Jun 25, 2026
Merged

Detect additional third-party coding agents#13722
BagToad merged 5 commits into
cli:trunkfrom
BagToad:bagtoad/extend-3p-agent-detection

Conversation

@BagToad

@BagToad BagToad commented Jun 24, 2026

Copy link
Copy Markdown
Member

Description

Extends agent detection so the User-Agent header can identify more third-party coding agents driving gh. Adds nine new agents and an extra environment-variable signal for one existing one.

Key Points

New agents detected: antigravity, augment-cli, replit, goose, cowork, cursor, cursor-cli, kiro, and pi. One existing agent gains an extra signal: claude-code also matches CLAUDE_CODE.

Detection order encodes confidence. AI_AGENT still wins, followed by agent-specific variables. Two signals are deliberately low-confidence and ranked accordingly:

  • REPL_ID is present throughout any Replit environment, not only when a Replit agent drives the CLI, so it is annotated as broad in the code.
  • GOOSE_PROVIDER only means Goose is configured as a model provider, not that it is running, so Goose is checked absolutely last and any stronger signal wins.

The single-source block now matches precisely instead of loosely: kiro is an exact TERM_PROGRAM match, and pi is anchored to a path boundary (/.pi/agent, or the Windows \.pi\agent) so an incidental substring cannot trigger it.

We considered a Devin signal and dropped it. The only reliable marker is the existence of a /opt/.devin directory, and this detector is intentionally environment-only with no filesystem access. The environment-variable alternatives (for example an EDITOR substring) could produce false positives, and Devin's developer-terminal footprint is small, so a noisy signal was not worth the telemetry pollution.

Notes for reviewers

Two files change. Start in the agents detector: the constant block lists the new identifiers, and detectWith runs the ordered checks top to bottom, returning on first match. Read it straight down to see the precedence. Then the detector tests add table cases for every new agent and signal, plus the precedence and negative cases (exact kiro, path-boundary pi, Goose losing to stronger signals).

First-party documentation for each signal lives inline next to its check, or is marked // No first-party docs where none exists.

Add detection for antigravity, augment-cli, replit, goose, cowork,
cursor, cursor-cli, kiro, and pi, plus extra signals for opencode and
claude-code. Low-confidence signals (Replit, Goose) and single-source
matches are checked last so stronger signals win.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed labels Jun 24, 2026
@BagToad BagToad marked this pull request as ready for review June 24, 2026 22:58
@BagToad BagToad requested a review from a team as a code owner June 24, 2026 22:58
@BagToad BagToad requested review from babakks and Copilot and removed request for Copilot June 24, 2026 22:58
@github-actions github-actions Bot added unmet-requirements and removed needs-triage needs to be reviewed labels Jun 24, 2026
@github-actions

Copy link
Copy Markdown

@babakks babakks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread internal/agents/detect.go Outdated
Comment thread internal/agents/detect.go
BagToad and others added 3 commits June 25, 2026 08:41
OPENCODE_CALLER and OPENCODE_CLIENT are set on the environment that
launches opencode, such as the VS Code extension's terminal, so they can
be present when a person rather than the agent runs gh. Detect only
OPENCODE, which opencode sets on its own process.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Pi PATH check only matched the POSIX separator. Also match the
Windows form so detection works there, with the caveat that Pi's Windows
layout is unconfirmed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 25, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends internal/agents detection logic so gh can identify additional third-party coding agents (via environment-variable signals) and encode a precedence order for conflicting signals, with accompanying table-driven tests.

Changes:

  • Adds new AgentName constants and detection checks for additional third-party agents (plus new Claude Code and Cursor signals).
  • Introduces “single-source” detection checks (e.g., exact TERM_PROGRAM match for Kiro, PATH-based signal for Pi) and places Goose’s provider signal last.
  • Expands TestDetectWith with cases for new agents, precedence, and negative matches.
Show a summary per file
File Description
internal/agents/detect.go Adds new agent identifiers and ordered environment-based detection logic.
internal/agents/detect_test.go Adds table-driven tests for new detectors and precedence/negative scenarios.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 5

Comment thread internal/agents/detect.go
Comment thread internal/agents/detect.go
Comment on lines +111 to +115
Comment thread internal/agents/detect.go
Comment thread internal/agents/detect_test.go
Comment thread internal/agents/detect_test.go
OPENCODE_CALLER and OPENCODE_CLIENT name the client that launched
opencode rather than the running agent, so a comment records why only
OPENCODE is checked.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BagToad BagToad enabled auto-merge (squash) June 25, 2026 15:12
@BagToad BagToad merged commit 561d9f9 into cli:trunk Jun 25, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants