Skip to content

feat: Add v0 detection, improve cursor detection#9

Merged
blainekasten merged 4 commits into
mainfrom
cursor/detect-agent-python-port-synchronization-410a
May 29, 2026
Merged

feat: Add v0 detection, improve cursor detection#9
blainekasten merged 4 commits into
mainfrom
cursor/detect-agent-python-port-synchronization-410a

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 29, 2026

Summary

  • Add upstream v0 detection via AI_AGENT=v0
  • Align Cursor detection with upstream: CURSOR_TRACE_ID detects Cursor and CURSOR_AGENT detects cursor-cli
  • Update tests, docs, changelog, version, and lock metadata

Verification

  • python3 -m pytest
  • python3 -m ruff check . && python3 -m ruff format --check .
Open in Web View Automation 

Co-authored-by: Blaine Kasten <blainekasten@gmail.com>
@cursor cursor Bot requested a review from blainekasten May 29, 2026 14:05
Comment thread detect_agent/__init__.py
return {"is_agent": True, "agent": {"name": PI}}

if os.environ.get("CURSOR_AGENT"):
if os.environ.get("CURSOR_TRACE_ID"):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@cursoragent can you do some web searching to see if these changes for the cursor agent detection are accurate? I think these changes are actually wrong based on my experience

Copy link
Copy Markdown
Contributor Author

@cursor cursor Bot May 29, 2026

Choose a reason for hiding this comment

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

Verdict: the Cursor detection change is accurate. No functional revert needed.

What I found:

  • Upstream @vercel/detect-agent maps:
    • CURSOR_TRACE_ID -> cursor
    • CURSOR_AGENT or CURSOR_EXTENSION_HOST_ROLE=agent-exec -> cursor-cli
  • Public Cursor Agent troubleshooting references use CURSOR_TRACE_ID to detect Cursor Agent terminal sessions.
  • Current Cursor Agent CLI artifact sets CURSOR_AGENT=1 for commands it executes and does not reference CURSOR_TRACE_ID.
  • The old CURSOR_INVOKED_AS == "agent" check looks weaker; Cursor CLI uses CURSOR_INVOKED_AS mainly to infer command name/binary, not as the runtime agent signal.

Action taken:

  • Added a code comment clarifying the two signals.
  • Clarified the changelog wording.
  • Committed/pushed: 329cb19 Clarify Cursor agent detection signals

Verification:

  • 48 passed
  • ruff check . passed
  • ruff format --check . passed

Env note: this cloud image lacked uv and python3.12-venv; I installed python3.12-venv to verify. For future agents, env setup prompt: “Install uv and Python venv support for this repo so uv sync --extra dev, pytest, and ruff work out of the box.”

Sources:

Open in Web Open in Cursor 

Co-authored-by: Blaine Kasten <blainekasten@gmail.com>
@blainekasten blainekasten marked this pull request as ready for review May 29, 2026 18:14
@blainekasten blainekasten changed the title Sync Python detect_agent with upstream detect-agent feat: Add v0 detection, improve cursor detection May 29, 2026
@blainekasten blainekasten merged commit 97e7e36 into main May 29, 2026
2 checks passed
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