skillfed

detect_agent

Detect if code is running in an AI agent or automated development environment

detect-agent v0.6.0 652.1K downloads/30d#5,545 on PyPI0
License unclear Active released

What it is and what it does

detect_agent is a lightweight utility that identifies whether code is executing inside an AI agent or automated development environment. It works by checking environment variables and conditions against a vendored list of detection rules sourced from Vercel's upstream detect-agent package, returning both a boolean flag and metadata about the detected agent if one is found.

The package supports detection of many AI coding assistants and development environments—including Cursor, Claude Code, GitHub Copilot, Devin, Gemini CLI, and others—plus a standard AI_AGENT environment variable that any tool can set to identify itself. It's designed for scenarios where application behavior needs to adapt based on whether a human or an AI agent is running the code, such as adjusting logging verbosity, enabling experimental features, or tracking telemetry differently.

Use it for:

  • Adapt application logging, error handling, or output formatting when running under an AI agent versus human execution.
  • Track telemetry and analytics separately for AI agent runs versus human-driven sessions.
  • Enable or disable experimental features conditionally based on whether an AI development tool is detected.
  • Implement custom behavior in libraries or frameworks when they detect they're running in an AI-assisted coding environment.
  • Support the AI_AGENT standard by setting it in your own tool to allow downstream code to detect your presence.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Detects whether code is running in an AI agent or automated development environment by checking environment variables and conditions against a curated list of known agents.

Yes, with a license caveat. The package is actively maintained, has zero dependencies, and solves a real problem for code that needs to behave differently in AI agent contexts. However, verify the actual license terms before use—the metadata does not declare one, which is a gap you should resolve before committing to a dependency.

Install

detect-agent on PyPI

pip

pip install detect-agent

uv

uv add detect-agent

poetry

poetry add detect-agent

Installing detect_agent

Before you install

Low friction installation with no runtime dependencies. Active maintenance as of 2026-08-12 with recent releases.

License in practice

License status is unclear—no SPDX identifier or raw license text is available in the package metadata. Verify the actual license terms before using in proprietary or restricted contexts.

Quickstart

from detect_agent import determine_agent

result = determine_agent()
if result["is_agent"]:
    print(f"Running in {result['agent']['name']} environment")

Requires Python 3.9 or later.

Verify before relying

  • Exact license under which detect_agent is distributed (SPDX identifier not provided).
  • How frequently the vendored agents.json is synced with upstream Vercel repository.
  • Whether detection rules cover all current AI coding assistants or if gaps exist.

Package facts

License not declared (unclear)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 2 days since the last release
Last repo commit
First released
Downloads 652,133/month — #5,545 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: detect_agent-0.6.0-py3-none-any.whl

Tags

detect ai agent environmentcheck if running in ai development toolidentify ai coding assistantai agent detectionautomated environment detectioncursor claude copilot detectionai_agent environment variable
ai-detectionenvironment-detectiondevelopment-tools

More Software Development packages

Further reading