feat: pre-compute model catalog for all configured models#1451
Open
lennney wants to merge 2 commits into
Open
Conversation
Owner
|
当前 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
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.
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.