Repository navigation
translator: preserve query string on Anthropic passthrough - #2844
Merged
Merged
Conversation
The Anthropic passthrough translator replaced :path with the backend messages path, which dropped the query string of the client request. Claude Code calls /v1/messages?beta=true, so the backend received /v1/messages without it. Read the query from the original path header and append it to the rewritten path. The AWS and GCP Anthropic translators override both SetRequestHeaders and RequestBody and build their own paths, so they are unchanged. Fixes theagentrouter#2842 Signed-off-by: kerthans <1255829396@qq.com>
✅ Deploy Preview for theagentrouter canceled.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
aabchoo
approved these changes
Oct 16, 2026
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.
Description
The Anthropic passthrough translator replaced
:pathwith the backend messages path (for example/v1/messages), which dropped the query string of the client request. Claude Code calls/anthropic/v1/messages?beta=true, so an Anthropic-schema backend received/v1/messageswithout?beta=true.This makes
anthropicToAnthropicTranslatorimplementRequestHeadersSetter. It reads the query from thex-ai-eg-original-pathheader, which extproc sets to the original client path, and appends it to the rewritten path inRequestBody.The AWS and GCP Anthropic translators embed this type but override both
SetRequestHeadersandRequestBodyand build their own paths, so their behavior is unchanged. A generic fix in the upstream processor would also touch backends that sign or build their own query strings (SigV4, GCP), so this keeps the change to the Anthropic passthrough.Tests: added cases to
TestAnthropicToAnthropic_RequestBodyfor a query string, a query string together with a model name override, and an original path without a query.go test ./internal/translator/ ./internal/extproc/ ./internal/endpointspec/andgolangci-lint run ./internal/translator/...pass.Related Issues/PRs (if applicable)
Fixes #2842
Special notes for reviewers (if applicable)
The count_tokens passthrough has the same pattern and could get the same change in a follow-up.
AI tools were used to help write this change. I reviewed the code and tests and understand them.