detect_agent
Detect if code is running in an AI agent or automated development environment
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Low friction installation with no runtime dependencies.
- Active maintenance as of 2026-08-12 with recent releases.
License · maintenance · safety
(unclear) — 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.
last release 2026-08-12 (2 days) · last repo commit 2026-08-12
0 known vulnerabilities (OSV.dev, 2026-08-14) · 652,133 downloads/mo, #5,545 on PyPI
Alternatives
Verify before relying
from detect_agent import determine_agent
result = determine_agent()
if result["is_agent"]:
print(f"Running in {result['agent']['name']} environment")- 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.
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 on it.
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
Before you install
Low friction installation with no runtime dependencies. Active maintenance as of 2026-08-12 with recent releases.
Requires Python 3.9 or later.
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")
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
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “detect ai agent environment”
- detect_agentDetects whether code is running in an AI agent or automated…
- opentelemetry-instrumentation-crewaiAdds OpenTelemetry tracing to crewAI agentic workflows, capturing LLM…
- microsoft-agents-a365-runtimeProvides core runtime utilities, environment configuration, and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also deepagents-code · vermin · google-agents-cli · lib-detect-testenv · claude-tap · serena-agent · plugin-scanner · ci-info · shellingham · opencode-agent-hub