模型切换失败:target model context window is unknown
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
**提交人**: 用户6538
**客户端版本**: 0.1.73
---
## 问题描述
在对话中切换模型时,部分模型无法切换成功,操作无响应。
## 错误信息
```
[PRECONDITION_FAILED] target model context window is unknown; runtime selection was not changed
```
来源:`maker:set-model` IPC handler
## 复现步骤
1. 在活跃会话中尝试切换到某些模型(如 `z-ai/glm-5.3-flash`)
2. 模型切换 UI 操作无效,模型未切换
3. 日志中出现上述 PRECONDITION_FAILED 错误
## 日志片段(脱敏)
```
Error occurred in handler for 'maker:set-model':
Error: [PRECONDITION_FAILED] target model context window is unknown; runtime selection was not changed
[WARN] provider change failed: ...
[INFO] modelAccess xd gateway models synced: 19
[INFO] provider-service loaded catalog from remote (model-access API)
```
## 分析
`xd gateway` 同步了 19 个模型到本地目录,但部分模型缺少 `contextWindow` 字段。Cindy 在切换模型前会检查 context window 大小,字段缺失时拒绝切换,导致用户无法使用这些模型。
## 期望行为
- 模型目录同步时应确保 `contextWindow` 字段完整;或
- 切换时若 context window 未知,给出提示而非静默失败
## 附加现象
同一会话中还出现了 API 400 错误:`Invalid chat format. Expected 'detail' field in image_url dict to be one of ['low', 'auto', 'high', 'original']`,可能也与模型/网关配置有关。
---
## 提交时的任务环境
仅代表提交时快照,不一定是故障环境。OS 来自提交客户端本机,不含 SSH 远端主机;Harness / 模型来自当前任务。与运行环境无关的反馈可忽略本段。
**版本区域**: CN
**OS**: darwin arm64 (25.4.0)
**Harness**: Claude Code
**Model ID**: ` claude-sonnet-4-6 `
**界面语言**: en
Contributor guide
Research direction
Start at the maker:set-model IPC handler and trace how the xd gateway catalog and provider-service populate contextWindow. Reproduce the failure with a model such as z-ai/glm-5.3-flash, then verify that models with missing contextWindow either receive complete catalog data or produce a visible explanation instead of silently failing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100