Add ai detection to include the agent or model using the cli Closes #459#462
Open
SeanAlexanderHarris wants to merge 3 commits into
Open
Add ai detection to include the agent or model using the cli Closes #459#462SeanAlexanderHarris wants to merge 3 commits into
SeanAlexanderHarris wants to merge 3 commits into
Conversation
… cli this should help with meta monitoring of agentic use of the CLI, assist with evals, potentially power optimisation for agent use
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
There was a problem hiding this comment.
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-Agentheader fromclient.Execute, optionally appendingagent/<name>when an agent env var is detected. - Introduce
agentenvpackage 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. |
This was referenced Jul 17, 2026
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Tested and the new header values propagate through to internal observabilty.