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:
@@ -1,5 +1,11 @@
|
||||
# Hermes Web UI -- Changelog
|
||||
|
||||
## [v0.50.123] — 2026-04-21
|
||||
|
||||
### Fixed
|
||||
- **Default model change surfaced stale value after model-list TTL cache landed** — `set_hermes_default_model()` now explicitly invalidates `_available_models_cache` after `reload_config()`. The 60s TTL cache introduced in v0.50.121 (#780) only invalidates on config-file mtime change, but `reload_config()` resyncs `_cfg_mtime` before `get_available_models()` runs — so the mtime check never fires and the POST response (plus downstream reads within the TTL window) returned the previous model until the cache expired. Root cause of the `test_default_model_updates_hermes_config` CI flake as well. (#788)
|
||||
- **Test teardown restores conftest default deterministically** — `test_default_model_updates_hermes_config` now restores to the conftest-injected `TEST_DEFAULT_MODEL` (via `tests/_pytest_port.py`) instead of reading the pre-test value from `/api/models`, so teardown is stable regardless of ordering. Also updates `TESTING.md` automated-test count to 1578. (#788)
|
||||
|
||||
## [v0.50.122] — 2026-04-21
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user