fix(config): invalidate model-list TTL cache on default-model change

set_hermes_default_model() calls reload_config() which resyncs _cfg_mtime,
so the mtime check inside get_available_models() never fires and the POST
response returns the stale cached default. Explicitly drop the TTL cache
after reload so the next read recomputes. Fixes the CI failure in
test_default_model_updates_hermes_config which the prior teardown-only
fix in this PR did not actually address.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nathan Esquenazi
2026-04-20 19:32:33 -07:00
parent 629d4290ed
commit e91325db25
2 changed files with 10 additions and 0 deletions

View File

@@ -800,6 +800,10 @@ def set_hermes_default_model(model_id: str) -> dict:
_save_yaml_config_file(config_path, config_data)
# Reload outside the lock — reload_config() acquires _cfg_lock itself.
reload_config()
# reload_config() resyncs _cfg_mtime to the new file mtime, so the mtime
# check inside get_available_models() won't trigger invalidation. Drop
# the TTL cache explicitly so the next call recomputes with the new model.
invalidate_models_cache()
return get_available_models()