Repository navigation
fix: 用 Codex 当前可用窗口替代过期的 272K 对齐回退 - #2594
Merged
ranxianglei merged 1 commit intoOct 10, 2026
Merged
ranxianglei merged 1 commit into
ranxianglei merged 1 commit into
Conversation
Contributor
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.214-master.059d67c # this exact build
npm install -g billion-context@master # always the newest merged build
|
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.
Codex 新模型缺席于 bili 发布时的模型表时,代理把客户端当前可用窗口重新裁到 272K 回退,长会话因此触发不必要的 preflight 502。本 PR 让已有的客户端窗口上报优先,并在无上报时读取本机 Codex 元数据;保留无证据情况下的原有回退。
Fixes #2593
问题和结果
gpt-6.1-sol的当前模型缓存给出context_window=373000、max_context_window=872000、有效比例 95%,基础配置给出model_context_window=1048576。客户端可用窗口为 828,400,输出预留 128,000 后为 700,400;旧实现却把同一请求裁到272000-68000=204000。实际排查记录显示客户端窗口为 828,400,且正式上游请求已接受 439,936 输入 tokens,随后代理仍以 204,000 拒绝请求。这里的 439,936 是上游 usage;约 507,906 是从代理失败日志推导的 preflight 估算,不能当成上游真实输入计量。修复不宣称上游最大容量,也不保证历史会话没有其他问题。
实现
compress.modelContextLimit仍直接生效;未显式设置时,Codex 请求的 plugin/runtime/launcher 窗口声明优先于本机缓存和旧快照。对齐仍为min(bili 预算, Codex 窗口),不会擅自提高 bili 的原预算。CODEX_HOME(默认~/.codex)下的models_cache.json和基础config.toml。只提取模型 slug、窗口和有效百分比,沿用最长前缀及单层 namespace 匹配。max_context_window时对显式窗口封顶;无该字段时采用显式配置;未配置时采用模型的 context/max;最后应用effective_context_window_percent,缺失时默认 95%,向下取整。官方语义依据:322bbf4d / ModelInfo usable_context_window;同一提交的 with_config_overrides。
回归证据
新增 10 个测试(8 个元数据/真实 preflight 测试、2 个本地 HTTP 代理测试)。
红绿验证:在未修改的上游
8e7bb129archive 中运行更新后的代理测试,原有 6 项通过,新增 2 项分别在272000 != 828400和272000 != 800000断言处失败;修复后的相关 26 项全部通过。这是合成回归和真实本地代理路径验证,不是导出/重放用户完整聊天。验证
最终验证基线:
8e7bb129440ff5d907f2c00c810bacc6a9517373;提交:e8748343479baf8164c841790a813df812a10c03。npm run typecheck:通过。npm test:5,311 项,5,283 通过,0 失败,28 跳过。npm run build、dist-import-annotations、git diff --check:通过。ACP_TEST_E2E_FAKE=1 node --import tsx --test tests/e2e/e2e-codex-fake.test.ts:真实 Codex CLI 0.161.0 + 本地假上游,8/8 通过,零模型额度。E2E_CHECK=1:CLI/dist 可用;本地真实上游127.0.0.1:8199/v1/models不可达。未执行需真实模型的ACP_TEST_E2E=1四阶段验证。边界
本机缓存只能代表代理自身 CODEX_HOME 下的基础配置。远程客户端、其他 profile、CLI
-c覆盖及自定义 catalog 应继续使用已有 launcher/runtime 窗口上报或显式compress.modelContextLimit;本 PR 不推测代理之外的配置。有效百分比和 bili 输出预留均保留,采用保守的输入预算。独立于 #2541 的取消生命周期修复;不包含摘要校准量尺、WS 接入、配置 schema、环境变量、kernel、版本或依赖变更。未修改运行中的插件、未重启 App,合并及发布由维护者决定。