Search by

ergebnis / agent-detector

localheinz

Provides a detector for detecting the presence of an agent.

Package info

github.com/ergebnis/agent-detector

pkg:composer/ergebnis/agent-detector

Statistics

Installs: 27 741 331

Dependents: 5

Suggesters: 0

Stars: 24

Open Issues: 0

2.0.0 2026-10-29 17:44 UTC

README

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();

Disabling the detection

To disable the detection, set the AGENT_DETECTOR_DISABLE environment variable to a non-empty value, for example, AGENT_DETECTOR_DISABLE=1. Detector::isAgentPresent() then returns false, even when an agent is present.

Supported agents

This package detects the presence of the following agents via environment variables. An environment variable counts only when it is set to a non-empty value, or to the value given in the table.

Agent Environment Variable
Amp AMP_CURRENT_THREAD_ID
Antigravity ANTIGRAVITY_AGENT
Augment AUGMENT_AGENT
Claude Code CLAUDECODE, CLAUDE_CODE, CLAUDE_CODE_IS_COWORK
Cline CLINE_ACTIVE
Codex CODEX_CI, CODEX_SANDBOX, CODEX_THREAD_ID
Cursor CURSOR_AGENT, CURSOR_EXTENSION_HOST_ROLE (when set to agent-exec)
Gemini CLI GEMINI_CLI
GitHub Copilot COPILOT_CLI
Goose GOOSE_TERMINAL
Grok GROK_AGENT
Junie JUNIE_DATA, JUNIE_SHIM_PATH
Kiro CLI AGENT_CONTEXT_OUT, AGENT_DISPLAY_OUT
OpenClaw OPENCLAW_SHELL
OpenCode OPENCODE, OPENCODE_CLIENT
Pi PI_CODING_AGENT

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 X.