From 44c0c2d4ac05eb7ee0e32d9002bdcdbe8589f7f6 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 7 Jun 2026 13:02:30 +0530 Subject: [PATCH] refactor(inventory): make force_fresh_nous_tier keyword-only + pin contract Follow-up to the salvaged perf fix. The new force_fresh_nous_tier param was inserted into list_authenticated_providers between custom_providers and max_models. Make it keyword-only (*) so a positional caller passing max_models as the 5th arg can never silently mis-bind it to the tier-refresh flag, and add a signature-contract test that fails if the keyword-only separator is later dropped. All in-repo callers already use keyword args; verified no caller breaks. --- hermes_cli/model_switch.py | 1 + tests/hermes_cli/test_inventory.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/hermes_cli/model_switch.py b/hermes_cli/model_switch.py index 1a28b904281..61a58d8754e 100644 --- a/hermes_cli/model_switch.py +++ b/hermes_cli/model_switch.py @@ -1178,6 +1178,7 @@ def list_authenticated_providers( current_base_url: str = "", user_providers: dict = None, custom_providers: list | None = None, + *, force_fresh_nous_tier: bool = False, max_models: int = 8, current_model: str = "", diff --git a/tests/hermes_cli/test_inventory.py b/tests/hermes_cli/test_inventory.py index 9450d46af50..e51c62a2701 100644 --- a/tests/hermes_cli/test_inventory.py +++ b/tests/hermes_cli/test_inventory.py @@ -217,6 +217,24 @@ def test_build_models_payload_can_force_fresh_nous_tier(): assert mock_list.call_args.kwargs["force_fresh_nous_tier"] is True +def test_list_authenticated_providers_force_fresh_is_keyword_only(): + """``force_fresh_nous_tier`` must be keyword-only on the public listing API. + + It was inserted between ``custom_providers`` and ``max_models``; making it + keyword-only ensures no positional caller passing ``max_models`` as the 5th + arg silently mis-binds it to the tier-refresh flag. Pin the contract so a + future signature edit that drops the ``*`` separator is caught. + """ + import inspect + + from hermes_cli.model_switch import list_authenticated_providers + + sig = inspect.signature(list_authenticated_providers) + param = sig.parameters["force_fresh_nous_tier"] + assert param.kind is inspect.Parameter.KEYWORD_ONLY + assert param.default is False + + def test_pricing_uses_cached_nous_tier_by_default(): rows = [_nous_row()] ctx = _empty_ctx(provider="nous", model="openai/gpt-5.5")