Skip to content

Name the coding agent running the CLI in X-Patchstack-Agent - #525

Merged
ejntaylor merged 1 commit into
mainfrom
report-coding-agent
Nov 27, 2026
Merged

ejntaylor merged 1 commit into
mainfrom
report-coding-agent

Conversation

@ejntaylor

Copy link
Copy Markdown
Member

When the CLI runs under a coding agent it recognises, every request now names that agent in an X-Patchstack-Agent header, so Patchstack can tell which agent set up the app. An app set up by an agent carries no trace of it in its packages or pages, so until now those apps showed no builder at all.

The agent is read from the variables each agent sets on the commands it runs:

Agent Variable
Amp AGENT=amp or AMP_CURRENT_THREAD_ID
Codex CODEX_THREAD_ID, CODEX_CI or CODEX_SANDBOX
Gemini CLI GEMINI_CLI
GitHub Copilot CLI COPILOT_CLI or COPILOT_AGENT_SESSION_ID
OpenCode OPENCODE
Claude Code CLAUDECODE or CLAUDE_CODE
Cursor agent CURSOR_AGENT
  • Only the agent's name is sent, never a variable's value, and the header is left out when no agent is recognised.
  • Amp also sets CLAUDECODE, so it is checked before Claude Code.
  • CURSOR_TRACE_ID is not used, because it is set in every Cursor terminal, including a person's own.
  • A marker set to 0, false or an empty string counts as unset.

README and AGENT-INSTALL.md list the new header next to X-Patchstack-Command and X-Patchstack-Trigger.

Verification

  • npx vitest run: 276 files, 4,808 passed, 7 skipped.
  • npm run typecheck: passes.
  • New tests in tests/report-context.test.ts cover each agent, Amp over Claude Code, Codex inside a Claude Code terminal, switched-off markers, a Cursor editor terminal, and the header being absent with no agent.

Still to do

This changes AGENT-INSTALL.md, so per CLAUDE.md the hostile field-test run (node field-test/run.mjs --persona hostile --rounds 3) is due right after the release that ships it.

When the CLI runs under a coding agent it recognises, every request now
names that agent: claude, codex, cursor, gemini, copilot, opencode or amp.
It is read from the variables each agent sets on the commands it runs.
Only the name is sent, never a variable's value, and nothing is sent when
no agent is recognised.

Amp also sets the Claude Code marker, so it is checked first. The README
and AGENT-INSTALL disclosure of what each request carries list the new
header.

Amp-Thread-ID: https://ampcode.com/threads/T-51d38d23-954d-4cce-b37c-122ef6f72630
Co-authored-by: Elliot Taylor <elliot.t@patchstack.com>
@coderbuds

coderbuds Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🎯 Elite quality (98%) — Focused addition of agent detection with documented precedence and tests for tricky cases like Amp over Claude.

📦 Small

🤖 Written by Amp — going by its own attribution. Unknown whether a person read it; agents can report that with the report-ai-usage-tool tool.

🟢 Low risk — 34 lines of code, and nothing that needs a person.

🔎 AI review passed — Coderbuds triage found nothing that should stop this merge.

See how your team is trending →

@ejntaylor
ejntaylor merged commit 767ecde into main Nov 27, 2026
28 checks passed
@ejntaylor
ejntaylor deleted the report-coding-agent branch November 27, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants