Skip to content

feat: pre-compute model catalog for all configured models#1451

Open
lennney wants to merge 2 commits into
BigPizzaV3:mainfrom
lennney:feat/model-catalog-precompute
Open

feat: pre-compute model catalog for all configured models#1451
lennney wants to merge 2 commits into
BigPizzaV3:mainfrom
lennney:feat/model-catalog-precompute

Conversation

@lennney

@lennney lennney commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What

Following the cc-switch pattern: pre-compute model_catalog.json for ALL models in profile.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 slow list-models-for-host RPC on every startup.

How

New function ensure_full_model_catalog():

  • Parses all models from model_list (comma/newline separated, with or without suffixes)
  • Reuses existing collect_catalog_entries() and build_model_catalog_json()
  • Writes model-catalogs/{profile_id}.json
  • Sets model_catalog_json in config.toml

No-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_window values to it.

Test Coverage (9 adversarial tests)

Test Edge Case
skips_when_model_list_and_model_are_empty Empty inputs → no-op
strips_model_list_suffixes_in_catalog [1M] suffixes stripped, windows respected
preserves_user_defined_model_catalog_json User's custom path never overwritten
skips_when_suffix_catalog_already_set No duplicate catalog files
handles_model_list_with_only_whitespace Whitespace → only current model
deduplicates_model_names Duplicate model names → single entry
respects_model_windows_for_context_window Per-model windows from model_windows JSON
handles_model_list_with_commas Comma-separated model_list
keeps_current_model_first_in_catalog profile.model always first entry

All 102 relay_config tests pass.

@BigPizzaV3

Copy link
Copy Markdown
Owner

当前 PR 的 Windows artifacts 检查仍然失败,暂时不能合并。最新 main 已包含 ChatGPT Desktop watcher 相关修复,请先 rebase/merge 最新 main,然后重新运行完整 CI;如果同步后仍失败,请根据失败日志修复并在 PR 中说明根因。合并前需要确保 Windows、macOS x64、macOS arm64 全部通过。

lennney added 2 commits July 13, 2026 16:51
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
@lennney lennney force-pushed the feat/model-catalog-precompute branch from 45ec970 to b1aa69b Compare July 13, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants