Repository navigation
refactor: move vertex partner body rewrites into the compatible config - #395
Merged
eric8810 merged 3 commits intoOct 29, 2026
Conversation
The compatible package's Assembly, provider and model config carry body_rewrite: Option<CompatibleBodyRewrite> next to the user's transform_request_body; transform_body runs the rewrite first. The MaaS and xAI providers on Vertex pick VertexMaas and VertexXai instead of setting the public callback, so their rewrites live with the protocol. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
30 of 57 tasks
cunninghamcard-bit
marked this pull request as ready for review
October 28, 2026 07:02
eric8810
approved these changes
Oct 29, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Vertex partner body rewrite 是逐行搬移,host rewrite 先于 user callback;其他 compatible 路径不受影响,现有 MaaS/xAI e2e 覆盖完整,16/16 CI 通过。Approve。
This was referenced Oct 29, 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.
RFC-0046 R5(清单见 #328):Vertex 上的 MaaS、xAI 两个托管变体对 Chat Completions 请求体的改写,从公开的
transform_request_body回调改成openai_compatible目录里的封闭枚举CompatibleBodyRewrite,与 #394 给 Vertex 上的 Claude 用的AnthropicBodyRewrite同一做法(RFC-0046 §3.5)。Before:
create_google_vertex_maas、create_google_vertex_xai各写一个私有函数(maas_request_body、xai_request_body),包成Arc<dyn Fn>塞进OpenAICompatibleProviderSettings.transform_request_body。托管变体的改写占用了用户回调的位置,配置不能打印也不能比较。After:两个函数搬进
openai_compatible/request_rewrite.rs,成为CompatibleBodyRewrite::{VertexMaas, VertexXai}的apply。托管变体在build(..)里选一个变体;协议包先跑这个改写,再跑用户的transform_request_body(只对 chat)。发出的请求不变:MaaS 上两个 Llama 4 模型没设max_tokens时补 8192,Vertex 上的 Grok 不发reasoning_effort。一、体系现状(概览)
上游:
aimux(master d30f834):
Claude on Vertex 在 #394 已改成
anthropic/request_rewrite.rs的AnthropicRequestUrl、AnthropicBodyRewrite。二、本 PR 改动(细节)
测试:
openai_compatible/tests/request_rewrite.rsmax_tokens,已设时不覆盖;xAI 删除reasoning_effort;托管改写先于用户回调运行vertex下 MaaS、xAI 的上游移植用例openai_compatible/tests里构造CompatModelConfig的三处body_rewrite: None改动规模:
公开 API 与行为
CompatibleBodyRewrite是pub(crate),build本来就是pub(crate),OpenAICompatibleProviderSettings.transform_request_body保留。检查
基于 master
d30f8343。cargo fmt --check、scripts/check_provider_boundaries.sh、cargo +1.99 clippy(providers 与 provider-utils,-D warnings)、cargo check --workspace、cargo doc、全部测试均通过。Generated by Claude Code