feat: Anthropic 模型路由支持 Codex OAuth 账号#1672
Open
JialinLiu-codedance wants to merge 1 commit intoWei-Shaw:mainfrom
Open
feat: Anthropic 模型路由支持 Codex OAuth 账号#1672JialinLiu-codedance wants to merge 1 commit intoWei-Shaw:mainfrom
JialinLiu-codedance wants to merge 1 commit intoWei-Shaw:mainfrom
Conversation
Anthropic model routing is explicitly configured, so Codex/OpenAI OAuth accounts can be treated as routed targets without expanding the default Anthropic scheduling pool. The gateway dispatch path reuses the existing OpenAI Responses compatibility forwarder when an Anthropic group selects an OpenAI OAuth account. Constraint: Codex account support is limited to platform=openai and type=oauth Constraint: Public API shapes and group/account schemas must remain unchanged Rejected: Add OpenAI OAuth accounts to the normal Anthropic candidate pool | would change default scheduling behavior Rejected: Add new routing fields | model_routing already stores explicit account IDs Confidence: high Scope-risk: moderate Directive: Do not allow OpenAI accounts into Anthropic default scheduling; only explicit model_routing hits may use this path Tested: pnpm test:run src/views/admin/__tests__/groupsModelRoutingAccounts.spec.ts Tested: pnpm typecheck Tested: go test ./internal/handler -run TestMessagesForwardRouteKind -count=1 Tested: go test -tags unit ./internal/service -run '^TestGatewayService_SelectAccountWithLoadAwareness$' -count=1 -v Not-tested: Full backend test suite
1e0d466 to
4d0483f
Compare
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.
修改范围
本次扩展 Anthropic 分组的显式模型路由能力,让
model_routing可以选择 Codex 账号(限定为OpenAI OAuth账号)作为路由目标。设计上保持现有 REST 接口、分组配置结构和账号表结构不变,并且不把 OpenAI OAuth 账号加入 Anthropic 分组的默认调度池,只有显式路由规则命中时才允许进入兼容转发路径。修改内容
anthropic账号与openai/oauth账号候选,并在候选与已选标签中标识Anthropic或Codex / OpenAI OAuth。model_routing命中分支中解析并校验 OpenAI OAuth 账号,继续保留可调度、模型支持、排除列表、分组绑定等运行时约束。GatewayHandler.Messages在选中 OpenAI OAuth 账号时复用现有 OpenAI Responses 兼容链路,将 Anthropic Messages 请求转发为 OpenAI Responses,再转换回 Anthropic 兼容响应。如何测试
pnpm test:run src/views/admin/__tests__/groupsModelRoutingAccounts.spec.tspnpm typecheckgo test ./internal/handler -run TestMessagesForwardRouteKind -count=1go test -tags unit ./internal/service -run '^TestGatewayService_SelectAccountWithLoadAwareness$' -count=1 -v