Repository navigation
feat: name the client product in the provider User-Agent - #382
Merged
Merged
Conversation
The model request User-Agent identified only the runtime (`stepcode (darwin
25.1.0; arm64)`), so a provider-side log could not tell which product or
release sent a request. Append the client as an RFC 9110 `product/version`
token after the runtime token:
stepcode (darwin 25.1.0; arm64) stepcode-cli/1.4.2
`getPiUserAgent(client?)` renders the value; `createModels({ userAgent })` and
per-request `userAgent` carry the identity to every adapter, and an invalid
half drops the client token instead of corrupting the runtime token. The
coding product resolves the pair from `STEP_CLIENT` and the build version in
one place, so `x-step-client` / `x-step-client-version` and the User-Agent
cannot drift apart.
liuedcson
requested review from
MelodyVAR,
Uking-xxx and
ZouR-Ma
as code owners
December 2, 2026 05:52
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.
Why
User-Agenton model requests identified only the runtime:A provider-side log could therefore not tell a stale desktop build from a current CLI, nor which release sent a request. The product name and version existed only in
x-step-client/x-step-client-version, so anything that reads just the User-Agent saw a single anonymous client.What
Append the client identity as an RFC 9110
product/versiontoken after the runtime token:getPiUserAgent(client?)renders the value; the no-argument form is unchanged.createModels({ userAgent })sets the identity once for every request the collection dispatches (session turns, compaction, and any othercompleteSimple()caller). A per-requestuserAgentoverrides it.ProviderRequestOptions.userAgentreaches all three adapters (anthropic-messages, openai-completions, openai-responses) and survivesbuildBaseOptions(), sostreamSimplekeeps it.resolveStepClientIdentity():STEP_CLIENT(defaultstepcode-cli) plusSTEPCODE_VERSION.x-step-client/x-step-client-versionnow read the same helper, so the header pair and the User-Agent cannot drift.ModelRuntimeseeds it from that helper and allows a host override viaCreateModelRuntimeOptions.userAgent.Hosts that set
STEP_CLIENT(stepcode-desktop,stepcode-web, an embedding host) get their own product token without further changes.Validation
pnpm run check— the type check, layer/boundary/entry-freeze/public-boundary guards, andcheck:browser-smokepass.biome check --error-on-warningspasses on every touched path; note that currentmainalready fails it onpackages/coding-agent/test/step-subagent-events.test.ts:1218(lint/style/useTemplate), which this PR does not touch.pnpm exec vitest --run test/user-agent.test.ts test/fetch-option.test.ts test/telemetry-options.test.ts test/models-runtime.test.ts(providers) — 48 passed.pnpm exec vitest --run test/step-client-identity.test.ts test/sdk-openrouter-attribution.test.ts test/step-trace-headers.test.ts test/step-environment.test.ts test/step-extension.test.ts(coding-agent) — 59 passed.test/user-agent.test.tsasserts the header actually sent on the wire by each adapter through a capturingfetch, plus the collection → request → provider precedence.sdk-openrouter-attribution.test.tsnow also asserts the session runtime hands the resolved identity to the provider.Docs
packages/providers/README.md(client identity section),packages/coding-agent/docs/step-integration.md, and theSTEP_CLIENTrow inenvironment-variables.md.