From e6ff4eacdb7fdde74cfb83586942a2465c5183e9 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 19 Aug 2026 00:14:44 -0700 Subject: [PATCH] fix(tools-config): widen stale-model picker guard to legacy image and video pickers Same bug class as the plugin image picker crash (#77238): an unguarded `current_model = default_model` fallback that can index the catalog with a key it doesn't contain when the provider's default drifts from its catalog. Applies the `default if default in catalog else next(iter(catalog))` guard to _configure_imagegen_model and _configure_videogen_model_for_plugin. --- hermes_cli/tools_config.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hermes_cli/tools_config.py b/hermes_cli/tools_config.py index cd82e58be2..599ec3abf1 100644 --- a/hermes_cli/tools_config.py +++ b/hermes_cli/tools_config.py @@ -3997,7 +3997,10 @@ def _configure_imagegen_model(backend_name: str, config: dict) -> None: config[cfg_key] = cur_cfg current_model = cur_cfg.get("model") or default_model if current_model not in catalog: - current_model = default_model + # The saved model may belong to another provider (shared config key) + # and the catalog default itself may have drifted — never index the + # catalog with a key it doesn't contain. + current_model = default_model if default_model in catalog else next(iter(catalog)) model_ids = list(catalog.keys()) # Put current model at the top so the cursor lands on it by default. @@ -4228,7 +4231,9 @@ def _configure_videogen_model_for_plugin(plugin_name: str, config: dict) -> None config["video_gen"] = cur_cfg current_model = cur_cfg.get("model") or default_model if current_model not in catalog: - current_model = default_model + # Same guard as the image pickers: a stale cross-provider model or a + # drifted default must not become an unindexable catalog key. + current_model = default_model if default_model in catalog else next(iter(catalog)) model_ids = list(catalog.keys()) ordered = [current_model] + [m for m in model_ids if m != current_model]