Skip to content

Add ai detection to include the agent or model using the cli Closes #459#462

Open
SeanAlexanderHarris wants to merge 3 commits into
mainfrom
459-add-agent-use-detection
Open

Add ai detection to include the agent or model using the cli Closes #459#462
SeanAlexanderHarris wants to merge 3 commits into
mainfrom
459-add-agent-use-detection

Conversation

@SeanAlexanderHarris

@SeanAlexanderHarris SeanAlexanderHarris commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This should help with meta monitoring of agentic use of the CLI, assist with evals, potentially power optimisation for agent use.

Appends agent/model to the User-Agent header along with Prolific CLI version.

Structure: prolific-oss/cli/, then — only when an agent or model is detected — a space-separated agent/ key/value token. is whatever version.Get() returns. This approach does rely on one of a handful of popular AI model env vars being set, or one of a couple of emerging conventional env vars being set - so it is not a guaranteed catch all, just a best attempt.

Examples

# Human-driven (no agent env var detected) — base only
prolific-oss/cli/1.0.3

# Agent-driven, branded tool (fixed slug)
prolific-oss/cli/1.0.3 agent/claude-code
prolific-oss/cli/1.0.3 agent/antigravity

# Agent-driven, generic var (forwards the env var's value)
prolific-oss/cli/1.0.3 agent/cursor        # from AI_AGENT=cursor

Tested and the new header values propagate through to internal observabilty.

… cli

this should help with meta monitoring of agentic use of the CLI, assist with evals, potentially power optimisation for agent use
@SeanAlexanderHarris SeanAlexanderHarris self-assigned this Jul 17, 2026
Copilot AI review requested due to automatic review settings July 17, 2026 00:21
@SeanAlexanderHarris
SeanAlexanderHarris requested review from a team as code owners July 17, 2026 00:21
@SeanAlexanderHarris SeanAlexanderHarris linked an issue Jul 17, 2026 that may be closed by this pull request
@prolific-snyk

prolific-snyk commented Jul 17, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds best-effort AI agent/model detection to the Prolific CLI’s HTTP User-Agent so downstream observability can attribute API traffic to agent-driven usage, while preserving the existing prolific-oss/cli/<version> base.

Changes:

  • Build and send a versioned User-Agent header from client.Execute, optionally appending agent/<name> when an agent env var is detected.
  • Introduce agentenv package to detect agent environment variables and validate a safe value for headers.
  • Add tests covering User-Agent composition and agent env var detection behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
client/client.go Constructs the new User-Agent string (version + optional agent token) for all API requests.
client/client_test.go Adds an HTTP test asserting Execute sends the expected User-Agent.
agentenv/agentenv.go Implements env-var based agent detection and header-safety validation.
agentenv/agentenv_test.go Adds unit tests for detection precedence and header-value validation.

Comment thread client/client_test.go Outdated
Comment thread agentenv/agentenv.go Outdated
Comment thread agentenv/agentenv.go
Comment thread agentenv/agentenv_test.go Outdated
Comment thread agentenv/agentenv_test.go
Comment thread agentenv/agentenv.go
Comment thread client/client.go
@SeanAlexanderHarris SeanAlexanderHarris changed the title Add ai detection to include the agent or model using the cli Closes #429 Add ai detection to include the agent or model using the cli Closes #459 Jul 17, 2026
This was referenced Jul 17, 2026
SeanAlexanderHarris and others added 2 commits July 17, 2026 02:13
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add agent use detection

4 participants