feat: pre-compute model catalog for all configured models#1451
Conversation
|
当前 PR 的 Windows artifacts 检查仍然失败,暂时不能合并。最新 |
Following the cc-switch pattern, generate a model_catalog.json for ALL models in profile.model_list during config application, not just those with context window suffixes. Previously, apply_model_catalog_to_config only generated a catalog when at least one model had a suffix like [1M]. Most users don't use suffixes, so Codex fell back to the slow app-server RPC on every startup. Now ensure_full_model_catalog runs after the suffix catalog and generates a complete catalog when none exists yet. Changes: - Add ensure_full_model_catalog() — parses all models from model_list, builds entries via collect_catalog_entries, writes catalog JSON, and sets model_catalog_json in config.toml - No-ops when catalog already set or model_list is empty - Called from all three apply paths after apply_model_catalog_to_config - Update two tests to expect catalog generation
Coverage: - skip when both model_list and model are empty - strip suffixes from catalog entries - preserve user-defined model_catalog_json path - skip when suffix catalog already set - handle whitespace-only model_list (current model still included) - deduplicate repeated model names - respect model_windows for per-model context_window - handle comma-separated model_list - keep current model first in catalog order
45ec970 to
b1aa69b
Compare
|
感谢提交。完整收集 最新 |
|
Codex++ maintainer review note 这个 PR 当前可合并,但 model catalog 预计算会影响 provider/catalog 生成路径,和近期 local_thread_catalog 修复、custom Responses catalog 兼容、以及 per-model context 配置都有交叉。直接合并前需要确认不会覆盖用户自有 catalog,也不会破坏现有按 profile 生成的 catalog 指针。 建议补充/确认:
The PR is mergeable, but it touches catalog ownership/generation semantics. Please revalidate against latest main before merge. |
What
Following the cc-switch pattern: pre-compute
model_catalog.jsonfor ALL models inprofile.model_list, not just those with context window suffixes like[1M].Why
Currently
apply_model_catalog_to_config()only generates a catalog when at least one model has a suffix (deepseek-v4-pro[1M]). Most users don't use suffixes — the catalog is never generated, and Codex falls back to the slowlist-models-for-hostRPC on every startup.How
New function
ensure_full_model_catalog():model_list(comma/newline separated, with or without suffixes)collect_catalog_entries()andbuild_model_catalog_json()model-catalogs/{profile_id}.jsonmodel_catalog_jsoninconfig.tomlNo-op when: catalog already set (by suffix engine or user), or model_list is empty.
Relationship to #1261: complementary — this pre-computes the full catalog; #1261 adds per-model
context_windowvalues to it.Test Coverage (9 adversarial tests)
skips_when_model_list_and_model_are_emptystrips_model_list_suffixes_in_catalog[1M]suffixes stripped, windows respectedpreserves_user_defined_model_catalog_jsonskips_when_suffix_catalog_already_sethandles_model_list_with_only_whitespacededuplicates_model_namesrespects_model_windows_for_context_windowmodel_windowsJSONhandles_model_list_with_commaskeeps_current_model_first_in_catalogprofile.modelalways first entryAll 102 relay_config tests pass.