Repository navigation
refactor: resolve preset base urls in preset - #392
Merged
Merged
Conversation
BaseUrl::Preset held a &'static PresetDescriptor and called preset::resolve_base_url, so the OpenAI-compatible layer imported the preset registry while presets build on the compatible layer, a cycle. Presets now hand the compatible layer a BaseUrl::Dynamic resolver of their own (PresetBaseUrl); the variant is gone and the compatible test uses its own resolver (RFC-0046 §3.3, R2). URLs are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
This was referenced Oct 28, 2026
…eset-base-urls-in-preset
#391 replaced the alias of the compatible completion model with a struct of its own; record that as a Breaking change, as review on #391 suggested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…eset-base-urls-in-preset
cunninghamcard-bit
marked this pull request as ready for review
October 28, 2026 03:27
eric8810
approved these changes
Oct 28, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
PresetBaseUrl 把 preset 解析移回 preset,explicit/env/params/default 优先级与 lazy 时机不变,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:兼容层的
BaseUrl有一个Preset { descriptor: &'static PresetDescriptor, params }分支,解析时调crate::preset::resolve_base_url。兼容层因此use crate::preset::PresetDescriptor,而 preset 本身建立在兼容层上,形成环(RFC-0046 §3.3 的兼容层 ↔ preset 环)。After:
BaseUrl::Preset删除。preset 在自己的模块里实现兼容层已有的ResolveBaseUrl(PresetBaseUrl),以BaseUrl::Dynamic交给兼容层;兼容层的生产代码不再认识 preset,依赖只剩 preset → 兼容层。每次请求解析一次、建 provider 时不读环境变量的时机不变,拼出的 URL 不变。这是 RFC-0046 R2(拆环)的第四个 PR,跟踪在 #328;前面是 #389、#390、#391。另外按 eric 在 #391 的建议,在 CHANGELOG 的 Breaking 里补上
OpenAICompletionModel从别名变成独立类型这一条。一、体系现状(概览)
上游:AI SDK 没有 preset 注册表(这是 aimux 扩展,RFC-0036);
createOpenAICompatible({ baseURL })只收一个字符串,包装它的包(例如 google-vertex 的 MaaS 合作模型)在自己那边算好 URL 再交进去,openai-compatible 不认识它们。aimux(本 PR 之前):
二、本 PR 改动(细节)
preset 这一侧的同一行为由
aimux-providers/tests/presets_test.rs:313the_base_url_variable_is_read_per_request覆盖(走真实的 preset 路径),本 PR 不改它。测试
cargo test(aimux-providers lib)tests/presets_test.rs(preset 模板、环境变量、每次请求解析)ResolveBaseUrl,断言不变体积
公开 API 与行为
BaseUrl、ResolveBaseUrl、resolve_base_url都是 crate 内部的。OpenAICompletionModel变化来自已合并的 refactor: give openai its own completion model #391,不是本 PR 的代码。检查
已合上 master
e76ffeee。cargo +1.99 fmt --check、cargo +1.99 clippy --workspace --all-targets --all-features -D warnings、cargo doc、scripts/check_provider_boundaries.sh、全量测试,均通过。🤖 Generated with Claude Code
https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW