feat: 扩展按模型上下文管理,支持自动压缩与模型元数据导入 - #1837
Open
dongyu23 wants to merge 3 commits into
Open
Conversation
dongyu23
force-pushed
the
feat/per-model-metadata
branch
from
August 11, 2026 16:01
438ae7e to
8daec15
Compare
Author
|
Fork CI using the same .github/workflows/pr-build.yml passed for commit e4bf126. Windows artifacts, cargo test --workspace, macOS x64 DMG, and macOS arm64 DMG all passed. The upstream pull_request workflow is currently action_required and needs maintainer approval before it can run. |
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.
背景
现有版本已经支持按模型配置上下文窗口。本次 PR 在此基础上继续扩展按模型的配置能力,使不同模型可以拥有更符合自身特性的上下文、自动压缩和能力元数据。
我近期观察到 DeepSeek 已开始原生适配 Responses API。随着 Responses API 被更多第三方模型提供商采用,模型之间在推理档位、工具能力、截断策略、响应格式和多模态支持方面的差异会越来越明显。继续让所有第三方模型沿用同一套默认能力配置,会限制实际使用效果,也会让用户难以根据模型特性进行调整。
目前 Codex 内置模型目录主要由 GPT/Codex 系列模型组成。对于内置目录中没有匹配到的第三方模型,原有回退逻辑会借用首个内置模型的字段结构和部分能力默认值。因此,未知模型可能继承与自身实际能力不一致的 GPT 模型配置,例如默认推理档位、verbosity、工具类型、截断策略和并行工具调用能力。
本 PR 继续沿用现有上下文管理和
model_catalog_json机制,为第三方 Responses 模型提供更具扩展性的配置方式。功能预览
管理器会根据当前模型名称匹配
models.json中相同slug的条目,并同步上下文窗口、自动压缩阈值和模型能力元数据。主要改动
按模型配置自动压缩
90%、84.5%context_window自动计算auto_compact_token_limit导入模型元数据
models.json导入入口models.json、模型对象数组和单个模型对象export default和module.exportsJSON 包装models数组中自动匹配同名slugslug时拒绝导入,避免覆盖错误配置导入内容除了上下文窗口和自动压缩阈值,还可以包含模型自身的能力字段,例如推理档位、verbosity、截断策略、并行工具调用、图片输入和供应商扩展字段。
模型名称同步
配置边界与默认值
context_window、auto_compact_token_limit等由 Codex++ 管理的字段不会作为普通元数据覆盖max_context_window、priority、visibility、supported_in_api等托管字段会被明确提示为未导入用户界面优化
max_context_window约束兼容性
model_list和model_windows配置格式验证
本地已完成:
npm test,74 项测试通过npm run checknpm run vite:buildgit diff --check本机当前没有 Rust 工具链,Rust 和跨平台打包由上述 CI 完成验证:
cargo test --workspace关联
本 PR 是 #1197 合并后对按模型上下文管理能力的后续扩展。
#931 记录了第三方模型上下文窗口未按配置生效的运行时问题。本 PR 继续沿用 Codex 原生
model_catalog_json机制,并扩展自动压缩和模型元数据配置。