mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
fix: restore zero-arg fetch_models_dev call on default paths
The branched call shape in get_provider_info/get_provider is deliberate: ~69 test sites across tests/hermes_cli and tests/gateway monkeypatch fetch_models_dev (and get_provider_info) with zero/single-arg lambdas. Passing allow_network= unconditionally broke 5 tests in CI slices 2/3/7. Documented the constraint inline.
This commit is contained in:
parent
11ca7eedf0
commit
ccf7129ed0
3 changed files with 19 additions and 4 deletions
|
|
@ -837,7 +837,14 @@ def get_provider_info(
|
|||
# Resolve Hermes ID → models.dev ID
|
||||
mdev_id = PROVIDER_TO_MODELS_DEV.get(provider_id, provider_id)
|
||||
|
||||
data = fetch_models_dev(allow_network=allow_network)
|
||||
# NOTE: keep the zero-argument call on the default path. Dozens of test
|
||||
# sites monkeypatch fetch_models_dev with zero-arg lambdas; passing the
|
||||
# kwarg unconditionally would break them all (they raise TypeError).
|
||||
data = (
|
||||
fetch_models_dev()
|
||||
if allow_network
|
||||
else fetch_models_dev(allow_network=False)
|
||||
)
|
||||
raw = data.get(mdev_id)
|
||||
if not isinstance(raw, dict):
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -450,7 +450,13 @@ def get_provider(name: str, *, allow_network: bool = True) -> Optional[ProviderD
|
|||
# Try to get models.dev data
|
||||
try:
|
||||
from agent.models_dev import get_provider_info as _mdev_provider
|
||||
mdev_info = _mdev_provider(canonical, allow_network=allow_network)
|
||||
# Keep the single-argument call on the default path: test sites
|
||||
# monkeypatch get_provider_info with single-arg lambdas.
|
||||
mdev_info = (
|
||||
_mdev_provider(canonical)
|
||||
if allow_network
|
||||
else _mdev_provider(canonical, allow_network=False)
|
||||
)
|
||||
except Exception:
|
||||
mdev_info = None
|
||||
|
||||
|
|
|
|||
|
|
@ -469,11 +469,13 @@ class TestFetchModelsDev:
|
|||
mock_fetch.assert_called_once_with(allow_network=False)
|
||||
|
||||
@patch("agent.models_dev.fetch_models_dev", return_value=SAMPLE_REGISTRY)
|
||||
def test_provider_info_default_allows_network(self, mock_fetch):
|
||||
def test_provider_info_default_preserves_zero_argument_fetch(self, mock_fetch):
|
||||
"""Default path must stay a zero-arg call: many test sites monkeypatch
|
||||
fetch_models_dev with zero-arg lambdas."""
|
||||
info = get_provider_info("anthropic")
|
||||
|
||||
assert info is not None
|
||||
mock_fetch.assert_called_once_with(allow_network=True)
|
||||
mock_fetch.assert_called_once_with()
|
||||
|
||||
def test_provider_definition_propagates_network_disabled(self):
|
||||
from hermes_cli.providers import get_provider
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue