[Bug] Codex 接入 DeepSeek 时上下文圆环显示兜底窗口 258.4K,用量占比虚高、过早红色告警
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
**提交人**: zyt
**客户端版本**: 0.1.26
---
## 现象
桌面端通过 Codex 使用 DeepSeek V4 Pro(或其他不在 Codex 内置 models.json 中的模型)时,上下文容量圆环/tooltip 显示总窗口为 258.4K。该值并非模型真实窗口(目录中为 1,048,576),而是 Codex 对未知模型的兜底窗口(272,000 × 95%)。导致:用量 100K 时圆环显示约 39%(真实应约 10%);用量约 245K 时已 ~95% 红色告警,compact 确认框显示 245K/258.4K 95%,严重虚高,用户会误以为上下文即将耗尽而过早压缩。
## 复现步骤
1. 新建 Codex 会话,选择 DeepSeek V4 Pro(或任意不在 Codex 内置 models.json 中的模型)
2. 对话使 token 用量达到几十 K
3. 观察上下文圆环/tooltip 占比
## 期望行为
- 圆环分母使用模型真实窗口 1M,占比按真实窗口计算
- 若无法获得真实窗口,应标识为"兜底估算值",不应把 fallback 窗口当真实值展示
## 实际行为
圆环分母为 Codex fallback 窗口 258.4K,占比虚高约 4 倍,过早变红。
## 根因(附源码引用)
1. Codex 对未知模型走 fallback:`codex-rs/models-manager/src/model_info.rs` 的 `model_info_from_slug()` 设 `context_window=272_000`、`effective_context_window_percent=95`,并置 `used_fallback_model_metadata=true`
2. Cindy 模型目录 `packages/model-providers/catalog/model-registry.json` 中 DeepSeek 条目 `contextWindow:1048576`,但未标记 `contextWindowVerified`
3. `packages/maker-core/src/agents/codex/index.ts` 的 `capContextWindow()` 仅对已验证窗口收敛,DeepSeek 未标记 → 兜底值 258,400 原样透传
4. UI `apps/desktop/src/renderer/lib/contextWindow.ts` 的 `resolveDisplayContextWindow()`:SDK 值 > 200K 时无条件采信,258.4K 成为圆环分母
5. Cindy 全仓库未消费 Codex 的 `used_fallback_model_metadata` 标志(全局搜索 0 处),UI 无法识别兜底值
## 建议修复方向
- 消费 Codex `used_fallback_model_metadata`,区分"兜底窗口"与"真实窗口"
- 对已知真实窗口的第三方模型补 `contextWindowVerified`
- 圆环对兜底窗口给出"估算"标识
---
**OS**: win32 x64 (10.0.26200)
**界面语言**: zh-CN
Contributor guide
Research direction
Start with capContextWindow() in packages/maker-core/src/agents/codex/index.ts and resolveDisplayContextWindow() in apps/desktop/src/renderer/lib/contextWindow.ts, then inspect the DeepSeek entry in packages/model-providers/catalog/model-registry.json. Trace whether Codex's used_fallback_model_metadata is available at the UI boundary. Done means the real 1M window is used when verified, while fallback values are identified as estimates rather than shown as actual capacity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100