Repository navigation
Name the coding agent running the CLI in X-Patchstack-Agent - #525
Merged
Merged
Conversation
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>
|
🎯 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 🟢 Low risk — 34 lines of code, and nothing that needs a person. 🔎 AI review passed — Coderbuds triage found nothing that should stop this merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the CLI runs under a coding agent it recognises, every request now names that agent in an
X-Patchstack-Agentheader, 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=amporAMP_CURRENT_THREAD_IDCODEX_THREAD_ID,CODEX_CIorCODEX_SANDBOXGEMINI_CLICOPILOT_CLIorCOPILOT_AGENT_SESSION_IDOPENCODECLAUDECODEorCLAUDE_CODECURSOR_AGENTCLAUDECODE, so it is checked before Claude Code.CURSOR_TRACE_IDis not used, because it is set in every Cursor terminal, including a person's own.0,falseor an empty string counts as unset.README and AGENT-INSTALL.md list the new header next to
X-Patchstack-CommandandX-Patchstack-Trigger.Verification
npx vitest run: 276 files, 4,808 passed, 7 skipped.npm run typecheck: passes.tests/report-context.test.tscover 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.