makecindy / makecindy/cindy

bug: 自定义供应商模型被错误回退路由到官方 XD 网关导致间歇性 400 报错

Open
#3,279 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

### 问题描述 / What happened

使用自定义供应商「Kimi Code」(baseUrl: api.kimi.com/coding,模型 k3,OAuth 凭据)时,对话间歇性报 API Error: 400: {'error': 'anthropic_messages: Invalid model name passed in model=k3. Call /v1/models to view available models for your key.'},点重试后通常恢复。经排查,该报错并非 Kimi 官方返回(直连官方端点一切正常,甚至不存在的模型名也能 200),而是 Cindy 本地代理在某些时刻(疑似 OAuth 凭据刷新失败时)把请求回退路由到了官方 XD 网关(api.laxarouter.ai),而 XD 网关模型列表中没有 k3,必然 400——我用账户 key 向 XD 网关发 model=k3 可 100% 复现同样报错。该问题与思考档位无关(high/xhigh/max 都出现过,日志均有记录)。建议:对 XD 网关不存在的自定义模型不要回退到 xd provider,或回退前先校验网关是否支持该模型,否则回退等于必然失败,还会让用户误以为是供应商配置问题。

### 环境 / Environment

- Cindy 版本或 commit / version or commit:0.1.58
- 平台与版本 / platform & OS version: Windows11,最新
- 安装方式 / install method:安装包安装

### 复现步骤 / Steps to reproduce

1. 在 设置 → 模型供应商 中添加自定义供应商:baseUrl 填 `https://api.kimi.com/coding`,添加模型 `k3`(Kimi Code 编程计划包月订阅,OAuth 授权)
2. 新建会话,选择该供应商的 `k3` 模型(Claude Code harness),正常对话使用
3. 间歇性地(疑似 OAuth 凭据刷新失败的瞬间),某次发送消息会直接报错:`API Error: 400: {'error': 'anthropic_messages: Invalid model name passed in model=k3. Call /v1/models to view available models for your key.'}`
4. 点「重试」通常恢复正常;问题与思考档位无关(high / xhigh / max 档位均出现过,会话日志可查)

补充说明(供定位):
- 该报错并非 Kimi 官方返回:直连 `api.kimi.com/coding` 一切正常,甚至发送不存在的模型名也返回 200
- 报错实际来自官方 XD 网关 `api.laxarouter.ai`:用账户 key 向该网关 `/v1/messages` 发送 `model=k3` 可 100% 复现完全相同的报错文案;该网关 `/v1/models` 列表中没有 `k3`
- 推测原因:kimi-code 请求在某时刻被回退路由到了 XD 网关(日志中可见 `falling back to official provider { providerId: 'xd' }`),而网关不认识自定义模型名,导致必然 400
- 建议:对 XD 网关不支持的自定义模型不要回退,或回退前校验模型可用性

### 日志与截图 / Logs & screenshots

Image

Contributor guide

Open the contributing guide

Research direction

Start by tracing the provider fallback path indicated by the `falling back to official provider { providerId: 'xd' }` log, using the Kimi Code `k3` setup and the `/v1/messages` and `/v1/models` behavior described in the issue. Done means a custom model is not sent to the XD gateway when unsupported, or its availability is validated before fallback, with the intermittent OAuth-refresh case covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.