feat(api): forward GITLAB_DUO_SESSION_ID as X-Gitlab-Duo-Session-Id header

Summary

  • Reads GITLAB_DUO_SESSION_ID environment variable in NewClientFromConfig
  • When set, injects X-Gitlab-Duo-Session-Id HTTP header on every outgoing API request
  • No behavior change when the env var is unset

This allows GitLab Duo agents that invoke glab to have their CLI actions traced back to the originating agent session.

Closes #8328 (closed)

Test plan

  • go test ./internal/api/... passes (new TestNewClientFromConfig_DuoSessionID covers both the injection and no-op paths)
  • Manual: GITLAB_DUO_SESSION_ID=test-session glab api projects — confirm X-Gitlab-Duo-Session-Id: test-session appears in request headers (e.g. via GLAB_DEBUG_HTTP=true)

🤖 Generated with Claude Code

Merge request reports

Loading