Repository navigation
Conversation
Report the AI agent driving the client as its own User-Agent token, between the library and the requesting app: ts-octopusdeploy AIAgent/ClaudeCode GitHubActions (release;deploy;v3) Callers that know the agent from a protocol, such as an MCP server with the connected client's clientInfo, can pass it as `aiAgent` in the client configuration. That takes precedence over AI_AGENT, which takes precedence over vendor-specific environment variables. Only a normalised agent name is sent. The agent list is ported from go-octopusdeploy, which is the reference implementation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T4ijpGHFpAqBBMhn5WKUq2
This branch has not been deployed
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.
Background
AI coding agents increasingly drive tools built on this client, including the Octopus MCP server, but the User-Agent doesn't identify that traffic. Unlike the Go and .NET clients, this client also has no environment detection at all today.
This ports the agent detection added to go-octopusdeploy in OctopusDeploy/go-octopusdeploy#419, so the server sees the same agent names from every client.
Results
When an agent is detected, the User-Agent gains an
AIAgent/<Name>token between the library and the requesting app:aiAgentconfiguration option. This takes a lesson from the MCP server, which learns the connected agent from the MCPinitializehandshake (clientInfo). That's a better signal than environment variables, so callers that know the agent can pass it in. It's mapped to a known name and takes precedence over environment detection.AI_AGENT, the emerging cross-vendor convention, mapped to a known name by prefix (e.g.claude-code_2-1-322_agent→ClaudeCode).AIAgent/Other, and raw values are never included.Testing
aiAgent.test.tscovers each agent's variables, value-matched rules, excluded variables, nested agents,AI_AGENTmapping and precedence, the caller-supplied agent, and that raw values never appear.createUserAgent.test.tscovers the assembled header.tscand ESLint pass. I only ran the unit test suites, not the integration tests that need a live Octopus instance.How to review this PR
The logic is in
src/aiAgent.ts.createUserAgent.tsreplaces the inline string building inaxiosAdapter.ts. The agent list is ported from go-octopusdeploy, which is the reference copy; a comment at the top of the file points there.Caveats
clientInfo.nameasaiAgent, so its requests carry the normalised name too.Generated by Claude Code