feat(api): detect coding agents in User-Agent header
Description
Appends a Coding-Agent/{name} token to glab's User-Agent header when an AI coding agent is detected, so GitLab can distinguish AI-agent traffic from human CLI usage.
- Detects Claude Code, Codex CLI, Cursor, and OpenCode via their documented sentinel env vars
AI_AGENTenv var takes priority and lets any agent self-identify without a glab releaseAI_AGENTvalues are validated against[A-Za-z0-9._-]+to keep the header well-formed- User-Agent becomes e.g.
glab/v1.97.0 (darwin, arm64) Coding-Agent/claude-code; unchanged when no agent is detected - Existing
^glab/vserver-side regex is unaffected (anchored to start)
Why env vars
Coding agents already set sentinel env vars in child processes. Reading those is zero-config and invisible to users. The AI_AGENT umbrella covers agents we haven't hardcoded yet.
Related Issues
Relates to gitlab-org/orbit/knowledge-graph#620 (closed)
How has this been tested?
Claude Code
Codex
OpenCode
Cursor
Edited by Jean-Gabriel Doyon