fix(codex): honor custom provider context windows - #3497
Conversation
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/maker-host/codex-custom-context-catalog.ts | 新增模型目录提取、目标 slug 上限修补和不可变目录持久化,校验与并发写入处理较完整。 |
| apps/desktop/src/main/maker-host/catalog-to-descriptors.ts | 仅为用户 Provider 中显式配置窗口的模型启用运行期覆盖,保持官方及网关路径不变。 |
| apps/desktop/src/main/maker-host/index.ts | 将 custom-context Host 接入隔离代理和派生模型目录启动参数,未发现独立的确定性路由错误。 |
| packages/maker-core/src/agents/codex/index.ts | 增加单会话 Host、窗口注入和模型切换保护,但启动失败后不会回收已创建的 custom-context Host。 |
| packages/maker-core/src/agents/base-agent.ts | 扩展 Host 依赖契约以传递 custom-context 目的、模型和窗口参数。 |
| packages/maker-core/src/agents/codex/index.test.ts | 覆盖成功启动、关闭回收和模型切换边界,但没有覆盖启动失败后的 Host 回收。 |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[自定义 Provider 会话] --> B[解析显式 Context window]
B --> C[提取 bundled 模型目录]
C --> D[抬高目标模型 max_context_window]
D --> E[创建单任务 App Server]
E --> F[thread/start 或 thread/resume]
F -->|成功| G[注入窗口与 95% 压缩阈值]
F -->|失败| H[当前仅释放 binding lease]
H --> I[Host 与 App Server 残留]
Prompt To Fix All With AI
### Issue 1
packages/maker-core/src/agents/codex/index.ts:4213
**启动失败遗留 Host**
当 custom-context App Server 创建后在 initialize、能力准备、`thread/start` 或 `thread/resume` 阶段失败时,这些分支只释放 binding lease 并抛错,而 Host 仅能通过成功返回的 handle 的 `close()` 回收,导致失败尝试遗留 Codex 进程;使用同一 sessionId 重试时还会复用首次尝试的静态模型目录。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(codex): honor custom provider contex..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a0b5c1b703
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@makecindy/maintainers 麻烦复审最新提交 |
|
本 PR 被维护者确认门拦住(架构:核心路径 + 大 diff)。 虽然标成 fix,但引入了自定义 Provider 的单任务 App Server、bundled 模型目录提取与定点修补,会改变本地 Codex 的宿主/目录行为。需要维护者确认这条路径可以合入。 讨论 issue:#3498 放行方式:维护者直接在本 PR 上 Approve。若要改,请 Request Changes;作者改完后再 Approve。评论或摘标签不能代替 Approve。 |
Signed-off-by: xujun <xujun@xd.com>
Signed-off-by: xujun <xujun@xd.com>
Signed-off-by: xujun <xujun@xd.com>
d1bee0f to
552a7a2
Compare
|
@makecindy/maintainers 已按 #3498 更新并 rebase 最新 main。最新提交 |
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
这次改了什么
摘要
修复自定义 Codex Provider 的
contextWindow只影响 Cindy 展示、却仍被 Codex 内置272K模型目录夹紧的问题。Codex 0.145 会用模型目录里的
max_context_window约束thread/start|resume传入的model_context_window。本 PR 对显式配置窗口的本地自定义 Provider 使用单任务 App Server,从当前 bundled Codex 二进制提取完整静态模型目录,只抬高所选真实 model slug 的max_context_window,并向 thread 注入实际窗口及 95% 自动压缩阈值。官方订阅、网关和远端 Codex 路径保持原行为。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
700000对应运行期665000。UI 变化
不涉及。
怎么验证的
自动验证
手工验证
Windows 11(10.0.22631)完整重启 Desktop 后,使用自定义 Provider 的
gpt-5.6-sol,配置contextWindow=700000。运行期首次及后续窗口回报均为665000,不再是258400;实际对话已验证可正常运行。另外用仓库 bundled
codex.exe完成 App Server 握手与 mock turn:原目录context_window=272000,修补后max_context_window=700000,运行期及 rollout token count 均为665000。未执行的验证
未在 macOS / Linux 上做 Desktop 实机验证;单测覆盖 LF / CRLF bundled 目录、目录跨 chunk 提取、并发持久化与缺失 slug 的 fail-closed 行为。
风险
风险分类
影响与回滚
CODEX_HOME/cindy-runtime/model-catalogs,不含凭证;目录外 slug 或目录预检失败时保留原共享 Host + Codex fallback metadata,精确目录修补阶段异常仍 fail closed。提交前检查
git commit -s,见 DCO)