Registry / testing / detect-agent

detect-agent

JSON →
library0.2.0pypypiunverified

Library to detect if Python code is running inside an AI agent (e.g., ChatGPT, Claude, Cursor agent) or automated development environment. Current version: 0.2.0. Release cadence: irregular.

pip install detect-agent
INSTALL
IMPORT
SIG · DETECT-AGENT
D
detect-agent
testingpythonv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

is_running_from_agent
from detect_agent import is_running_from_agent
from detect_agent import is_running_from_agent

Basic usage to detect if code is executed by an AI agent.

from detect_agent import is_running_from_agent if is_running_from_agent(): print('Running inside an AI agent environment') else: print('Not running inside an AI agent')
Debug
Known issues
gotchaThe detection logic relies on environment variables (e.g., CURSOR_ENV, GITHUB_COPILOT) that can be spoofed or absent, leading to false negatives/positives.
fix
Do not rely solely on this library for security-critical decisions; use it for soft gating.
affects: all
deprecatedThe function `is_running_from_pi_agent` was added in 0.2.0; older versions do not have it.
fix
Upgrade to 0.2.0 or check version before calling.
affects: <0.2.0
gotchaThe library may not detect all agents; it is limited to a curated list of known environment signals.
fix
Contribute upstream or extend detection logic locally.
affects: all
Upgrade
Version history
0.2.0latest on PyPI · released Apr 15, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
detect-agent — pip install detect-agent · libregistry