agent-detector

May 7, 2026 ยท View on GitHub

Integrate Merge Release Renew

Code Coverage

Latest Stable Version Total Downloads Monthly Downloads

This project provides a composer package with a detector for detecting the presence of an agent.

Installation

Run

composer require ergebnis/agent-detector

Usage

Detecting the presence of an agent

<?php

declare(strict_types=1);

use Ergebnis\AgentDetector;

$detector = new AgentDetector\Detector();

$isAgentPresent = $detector->isAgentPresent(\getenv());

Supported agents

This package detects the presence of the following agents via environment variables:

AgentEnvironment Variable
AmpAMP_CURRENT_THREAD_ID
AntigravityANTIGRAVITY_AGENT
AugmentAUGMENT_AGENT
Claude CodeCLAUDECODE, CLAUDE_CODE, CLAUDE_CODE_IS_COWORK
CodexCODEX_CI, CODEX_SANDBOX, CODEX_THREAD_ID
CursorCURSOR_AGENT, CURSOR_EXTENSION_HOST_ROLE, CURSOR_TRACE_ID
Gemini CLIGEMINI_CLI
GitHub CopilotCOPILOT_ALLOW_ALL, COPILOT_CLI, COPILOT_GITHUB_TOKEN, `COPILOT_MODEL
OpenCodeOPENCODE, OPENCODE_CLIENT
PiPI_CODING_AGENT
ReplitREPL_ID

Indicating the presence of an agent

In addition, the generic AI_AGENT environment variable can be set to indicate the presence of an agent.

Changelog

The maintainers of this project record notable changes to this project in a changelog.

Contributing

The maintainers of this project suggest following the contribution guide.

Code of Conduct

The maintainers of this project ask contributors to follow the code of conduct.

General Support Policy

The maintainers of this project provide limited support.

PHP Version Support Policy

This project currently supports the following PHP versions:

The maintainers of this project add support for a PHP version following its initial release and may drop support for a PHP version when it has reached its end of life.

Security Policy

This project has a security policy.

License

This project uses the MIT license.

Credits

The agent detector is inspired by shipfastlabs/agent-detector, originally licensed under MIT by Pushpak Chhajed.

Social

Follow @localheinz and @ergebnis on Twitter.