Repository navigation
refactor: give anthropic hosts an anthropic config - #394
Merged
eric8810 merged 2 commits intoOct 28, 2026
Merged
Conversation
AnthropicModelConfig becomes AnthropicConfig with the upstream members as its own fields: build_request_url (AnthropicRequestUrl), body_rewrite (AnthropicBodyRewrite), supports_native_structured_output and supports_strict_tools, beside the user's transform_request_body and the host's error handler. AnthropicModelHooks and its fn-pointer body hook go. The Vertex rawPredict URL and envelope move into anthropic/request_rewrite.rs as enum variants, so Vertex only picks them (RFC-0046 §3.5). Claude Platform on AWS keeps the Messages URL: its regional host is the base URL its endpoint resolves. URLs and bodies on the wire are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Boundary rule 6 banned the builder-era AnthropicConfig. The name now belongs to the RFC-0046 §3.5 model config, so the rule keeps checking the builder-era fields (body_overrides, api_key_source, from_env) only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
cunninghamcard-bit
marked this pull request as ready for review
October 28, 2026 04:03
30 of 57 tasks
eric8810
approved these changes
Oct 28, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
AnthropicConfig + AnthropicRequestUrl/body rewrite 逐项等价,三路 host 的 flags/handler/header 保持,cycle 断开;CI 通过。Approve。
This was referenced Oct 28, 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.
Before:Anthropic 模型的配置叫
AnthropicModelConfig,各宿主的差异装在一个子结构AnthropicModelHooks里:URL 用MessagesUrl,请求体改写是函数指针prepare_body: Option<fn(Value) -> Value>,Vertex 的rawPredict信封函数和anthropic_version常量写在 Vertex 目录里。After:配置改名
AnthropicConfig(上游的类型名),上游的几个成员直接成为它的字段:build_request_url: AnthropicRequestUrl、body_rewrite: Option<AnthropicBodyRewrite>、supports_native_structured_output、supports_strict_tools,旁边是用户回调transform_request_body和 aimux 的错误处理器。URL 和请求体改写是协议目录里的封闭枚举(anthropic/request_rewrite.rs),Vertex 只选变体。线上的 URL 和请求体不变。这是 RFC-0046 R3(托管变体改用
AnthropicConfig,§3.4、§3.5)的第一个 PR,跟踪在 #328。一、体系现状(概览)
上游(@ai-sdk/anthropic 4.0.71、@ai-sdk/google-vertex 5.0.100):
aimux(本 PR 之前):
二、本 PR 改动(细节)
与 RFC §3.5 草图的两处出入,记在这里:
AnthropicRequestUrl没有AwsRegional:Claude Platform on AWS 的区域主机是它的ResolveEndpoint解析出的 base URL(refactor: resolve anthropic host endpoints outside anthropic #390),URL 本身就是{base_url}/messages,与上游createAnthropicAws不传buildRequestUrl一致。AnthropicBodyRewrite没有Bedrock:Bedrock Converse 是独立协议,不经过 Anthropic 模型。测试
vertex/tests/anthropic/anthropic_provider.rs):rawPredict结尾、请求体带anthropic_version、没有model的断言照旧通过体积
公开 API 与行为
AnthropicConfig、两个枚举都是 crate 内部的;公开的TransformRequestBody不动。检查
基于 master
e76ffeee。cargo +1.99 fmt --check、scripts/check_provider_boundaries.sh、cargo +1.99 clippy -p aimux-providers --lib --tests -D warnings、cargo check --workspace --tests、cargo doc -D warnings、aimux-providers 全部测试,均通过。Generated by Claude Code