Repository navigation
fix(desktop): 绑定本机 Agent API 的 Claude 供应商路由 - #12339
Open
amanayayatu-tech wants to merge 1 commit into
Open
amanayayatu-tech wants to merge 1 commit into
amanayayatu-tech wants to merge 1 commit into
Conversation
Signed-off-by: amanayayatu-tech <267095040+amanayayatu-tech@users.noreply.github.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] 本次改动看起来可以合并,未发现需要阻止合并的问题。
|
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.
这次改了什么
摘要
本机 Agent API 已能用精确模型 ID 选定供应商。不可见的本机 Claude Code 会话跳过了普通任务的供应商登记,网关也无法用原生请求 ID 找到其句柄。同名模型因此落入歧义分支并返回 503。
在启动这类会话前登记实际执行路由,并让网关按当前句柄的请求 ID 找到绑定。已确认关闭、启动异常和指令重建的清理沿用会话生命周期。普通会话和远端托管会话保留现有的查找顺序。
变更类型
fix缺陷修复范围
UI 变化
不涉及。
怎么验证的
Mac 实机
在 Apple Silicon Mac 从
b3552640c4ed946ae24a3faef1f30bcb234f5a86和应用补丁后的同一工作树分别启动命名隔离 Desktop。两个本地测试服务监听随机回环端口,分别配置独立测试密钥。A、B 同时提供deepseek-v4.1-flash-1017,A 另提供只有自己有的fixture-12325-single。两个服务在/v1/messages返回带各自标记的 Anthropic SSE 响应并记录调用。使用 Claude Code 2.1.321 和临时配置,夹具将 CLI 重试上限设为 1。POST /rpc调用models,验证同名模型有不同的精确 ID。用 A 的 ID 调用session/open,传入toolPolicy: "client-only"、空工具数组和临时 cwd,再调用send并轮询events。turn_end为failed,SDK 显示 503 和“matches multiple connected Providers”,A、B 均收到零次请求。单来源模型正常完成。completed和 A 的标记,A 收到 1 次请求,B 收到 0 次。单来源模型继续正常。并行运行选 A 和选 B 的两个会话,各自命中所选上游。关闭 A 后 B 继续完成,关闭的会话拒绝send和events,重新使用同一客户端会话 ID 选 B 能正常运行。未授权请求和另一应用授权读取或关闭原会话均被拒绝。自动验证
runtime.integration.test.ts、server.integration.test.ts、claudeProxyImplicitRoute.test.ts、sessionProviderStore.test.ts,使用--maxWorkers=1。pnpm --filter desktop run --if-present typecheck。node scripts/check-test-hygiene.mjs与git diff --check。runtime.integration.test.ts的回归入口是openLocalAgentRuntime和网关使用的请求 ID 反查。旧测试覆盖应用生命周期和选组,未检查本机 Claude 的最终供应商登记与释放。最小失败输入是两个不可见的本机 Claude 句柄分别选择同名模型的不同供应商,修前启动后读到空绑定。新增断言覆盖关闭隔离、重建失败和授权关闭后的迟到句柄。Integration tier 使用可控句柄和系统临时目录,单文件实跑 2.11 秒。未执行的验证
本地未跑整仓检查与 Windows 实机。
风险
绑定写入现有 Main 内存路由表。网关仍经原有 owner 边界、当前供应商路由和授权规则选凭据。只有已选本机执行的不可见 Claude 会话进入此查找范围,启动失败和确认关闭后释放绑定,无持久化或迁移。回滚此提交即可恢复现有行为。
F 10/10(同一 Mac 双来源夹具两次符合条件的发送均复现,实际用户群频率未知),S 8/10(受影响 API 会话的推理主流程被阻断,两个上游均未收到请求)。