{"id":27689,"library":"detect-agent","title":"detect-agent","description":"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.","status":"active","version":"0.2.0","language":"python","source_language":"en","source_url":"https://github.com/togethercomputer/detect_agent","tags":["agent detection","environment check","AI agent","cursor","copilot","automation"],"install":[{"cmd":"pip install detect-agent","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"The package uses underscores in module name.","wrong":"","symbol":"is_running_from_agent","correct":"from detect_agent import is_running_from_agent"},{"note":"Added in 0.2.0.","wrong":"","symbol":"is_running_from_pi_agent","correct":"from detect_agent import is_running_from_pi_agent"}],"quickstart":{"code":"from detect_agent import is_running_from_agent\n\nif is_running_from_agent():\n    print('Running inside an AI agent environment')\nelse:\n    print('Not running inside an AI agent')","lang":"python","description":"Basic usage to detect if code is executed by an AI agent."},"warnings":[{"fix":"Do not rely solely on this library for security-critical decisions; use it for soft gating.","message":"The detection logic relies on environment variables (e.g., CURSOR_ENV, GITHUB_COPILOT) that can be spoofed or absent, leading to false negatives/positives.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to 0.2.0 or check version before calling.","message":"The function `is_running_from_pi_agent` was added in 0.2.0; older versions do not have it.","severity":"deprecated","affected_versions":"<0.2.0"},{"fix":"Contribute upstream or extend detection logic locally.","message":"The library may not detect all agents; it is limited to a curated list of known environment signals.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `from detect_agent import is_running_from_agent` (underscore, not hyphen).","cause":"Package name has hyphen, but Python module uses underscore. Importing as 'detect-agent' fails.","error":"ModuleNotFoundError: No module named 'detect_agent'"},{"fix":"Upgrade detect-agent to 0.2.0 with `pip install --upgrade detect-agent`.","cause":"Function only exists in version 0.2.0 and later; older versions lack it.","error":"AttributeError: module 'detect_agent' has no attribute 'is_running_from_pi_agent'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}