--- id: detect-agent version: "0.6.0" license: unclear license_treatment: unclear maintenance: active --- # detect_agent — Detect if code is running in an AI agent or automated development environment License: unclear · Maintenance: active · Downloads: 652.1K/mo ## 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 above — 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 pip install detect-agent uv add detect-agent 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_current - Install friction: low - Maintenance: active - Downloads: 652.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags detect ai agent environment, check if running in ai development tool, identify ai coding assistant, ai agent detection, automated environment detection, cursor claude copilot detection, ai_agent environment variable, ai-detection, environment-detection, development-tools [View on SkillFed](https://skillfed.io/packages/detect-agent) · [View on PyPI](https://pypi.org/project/detect-agent/)