-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Problem
Scripts and CLIs can detect CI environments via the CI=true convention, enabling non-interactive behavior and CI-appropriate output. It seems there's no equivalent for AI coding agents.
When agents execute commands, scripts have no way to know they're running in an agent context. This matters because:
- Error output — Agents benefit from structured errors (JSON with actionable suggestions) rather than human-friendly prose
- Verbosity — Agents can process more context; humans need scannable output
- Interactivity — Like CI, agents can't respond to prompts, but the existing
CI=truedoesn't capture the full picture
Use cases
# Script adapts output format
if [[ -n "${AGENT:-}" ]]; then
echo '{"error": "config_missing", "suggestion": "run ./setup.sh", "docs": "https://..."}'
exit 1
else
echo "Error: Config file not found. Run ./setup.sh to initialize."
exit 1
fi# Test runner provides richer failure context for agents
if [[ -n "${AGENT:-}" ]]; then
pytest --tb=long --verbose "$@"
else
pytest "$@"
fiProposal
Agents set an environment variable when executing commands:
| Variable | Value | Meaning |
|---|---|---|
AGENT |
1 |
Running under an AI coding agent |
Precedent
CI=true— Set by GitHub Actions, GitLab CI, CircleCI, Travis, Jenkins, etc.NO_COLOR=1— Disables color output across CLIsTERM=dumb— Signals limited terminal capabilities
The CI convention emerged organically as tools independently adopted it. A coordinated standard would accelerate adoption for agents.
Open questions
- Variable name —
AGENT,AI_AGENT,AGENTIC,LLM_AGENT? - Scope — Should this cover all automation (like
CI) or specifically AI agents? - Relationship to
CI— Should agents also setCI=true, or is this orthogonal?
Prior art
- InfoQ: Patterns for AI Agent Driven CLIs — Recommends
--no-interactiveflags and structured output, but no env var convention - OpenAI Codex uses
CODEX_SANDBOX=1internally for sandbox detection - No cross-agent standard exists today
Hopefully this is the right place to propose such standard, let me know if I should post this somewhere else.
Metadata
Metadata
Assignees
Labels
No labels