feat(provider): identify outbound LLM requests with a Reasonix User-Agent#5228
Open
xiongdi wants to merge 2 commits into
Open
feat(provider): identify outbound LLM requests with a Reasonix User-Agent#5228xiongdi wants to merge 2 commits into
xiongdi wants to merge 2 commits into
Conversation
…gent (esengine#5226) Outbound provider requests carried no User-Agent, so Go's default "Go-http-client/1.1" went out and an upstream gateway/proxy could not attribute traffic to Reasonix. Add a small buildinfo package that owns the build version (set once in cli.Run from the -ldflags-injected value, falling back to "dev") and exposes UserAgent() == "Reasonix/<version>". The openai and anthropic providers now set this User-Agent on every request. This is the zero-config subset of esengine#3824 (fully user-configurable headers): no config or UI, just a stable, well-known field gateways can match on. Co-authored-by: Cursor <cursoragent@cursor.com>
…umbing Simplify the change in response to review: instead of a buildinfo package threading the build version into "Reasonix/<version>", the openai and anthropic providers just send a constant `User-Agent: Reasonix`. Removes internal/buildinfo and the cli.Run wiring; keeps the identifying header (and its provider tests). Co-authored-by: Cursor <cursoragent@cursor.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.
Summary
Closes #5226.
Outbound LLM requests carried no
User-Agent, so Go's defaultGo-http-client/1.1was sent and an upstream gateway/proxy had no way to tell a request came from Reasonix.The
openaiandanthropicproviders now set a fixedUser-Agent: Reasonixon every request (alongside the existingContent-Type/Authorization/Accept/x-api-key/anthropic-versionheaders). No version, no config, no new package — just a stable, well-known field that gateways can match on.This is the zero-config subset of #3824 (fully user-configurable headers). It intentionally does not touch MCP HTTP headers (already handled by #5073) or webfetch's deliberate browser-like UA.
Cache-impact: none - only a transport-level
User-AgentHTTP header is added;buildRequest/message serialization and the JSON body sent to the model are unchanged, so the prompt-cache key (DeepSeek/OpenAI/Anthropic prefix caching keys on the message body, not request headers) is unaffected.Cache-guard:
buildRequestand the wire message structs are untouched; existing prefix-cache guards (internal/provider/openai/realcache_test.go,cachehit_e2e_test.go) still pass, and the newTestStreamSendsReasonixUserAgentin both providers only asserts the outbound header.Test plan
go build ./...go vet ./internal/provider/... ./internal/cli/...go test ./internal/provider/openai/... ./internal/provider/anthropic/...TestStreamSendsReasonixUserAgentin both providers asserting the outboundUser-AgentisReasonix.User-Agent: Reasonixappears.