HERMES-GIELIE/tests/test_openai_api_provider_alias.py

70 lines
2.8 KiB
Python
Raw Normal View History

Release v0.51.223 — Release GQ (stage-p5 — openai-api first-class picker provider #3443 + MiniMax-M3 #3374) (#3453) * feat: upgrade MiniMax default model to M3 Add MiniMax-M3 as the new default and prune deprecated older versions (M2.5/M2.5-highspeed/M2.1/M2) from the model catalog. M2.7 (and M2.7-highspeed) is retained as the legacy compatible option for users who pin to it. Updated: - api/config.py: _FALLBACK_MODELS adds minimax/MiniMax-M3 (placed before M2.7 so the dropdown surfaces it first) - api/config.py: _PROVIDER_MODELS['minimax'] adds M3 first, removes M2.5/M2.5-highspeed/M2.1 - api/config.py: _PROVIDER_MODELS['minimax-cn'] adds M3 first, removes M2.5/M2.1/M2 - tests/test_minimax_provider.py: updated CN catalog assertions to match the new {M3, M2.7} list API URL and TTS configuration are unchanged. Co-Authored-By: Octopus <liyuan851277048@icloud.com> * fix(models): register openai-api as first-class picker provider * fix(models): detect OPENAI_API_KEY as openai-api, not bare openai (#3443 Codex follow-up) Codex review found #3444 added the openai-api picker entry but the env-detection side still did detected_providers.add('openai') for OPENAI_API_KEY. The agent registry has only openai-api and openai-codex (no bare openai), so a env-only OPENAI_API_KEY setup emitted @openai: picker entries the agent can't resolve on the send path. Detect openai-api to match the registry. Adds a regression test. * docs(changelog): v0.51.223 — re-stamp keep-set (#3443 openai-api + #3374 MiniMax-M3); dropped #3289 + #3264 to hold per Codex --------- Co-authored-by: octo-patch <octo-patch@github.com> Co-authored-by: Octopus <liyuan851277048@icloud.com> Co-authored-by: Rod Boev <rod.boev@gmail.com> Co-authored-by: nesquena-hermes <[email protected]>
2026-06-03 01:08:01 +00:00
"""openai-api as a first-class picker provider.
hermes-agent registers its built-in OpenAI provider as ``openai-api`` in
``hermes_cli.auth.PROVIDER_REGISTRY``. The WebUI must recognise this
slug in ``_PROVIDER_DISPLAY`` and ``_PROVIDER_MODELS`` so that GPT
models appear in the picker AND the session ``model_provider`` stays
``openai-api`` on the send path (where the agent resolves it against
its own registry).
An alias-only approach (``openai-api`` → ``openai``) fixes display but
breaks the send path because ``openai`` is not a registered provider in
the agent. See PR review discussion on #3444.
"""
import api.config as cfg
class TestOpenaiApiPickerProvider:
"""openai-api must be a first-class picker provider, not an alias."""
def test_provider_display_registered(self):
assert "openai-api" in cfg._PROVIDER_DISPLAY
def test_provider_models_registered(self):
assert "openai-api" in cfg._PROVIDER_MODELS
assert len(cfg._PROVIDER_MODELS["openai-api"]) > 0
def test_not_aliased(self):
assert "openai-api" not in cfg._PROVIDER_ALIASES
def test_canonicalise_preserves_slug(self):
assert cfg._canonicalise_provider_id("openai-api") == "openai-api"
def test_openai_canonical_unchanged(self):
assert cfg._canonicalise_provider_id("openai") == "openai"
def test_openai_codex_unchanged(self):
assert cfg._canonicalise_provider_id("openai-codex") == "openai-codex"
class TestOpenaiApiSendPath:
"""The send path must preserve openai-api, not collapse it to openai."""
def test_resolve_model_provider_preserves_openai_api(self, monkeypatch):
monkeypatch.setattr(cfg, "cfg", {
"model": {"provider": "openai-api", "default": "gpt-5.5"},
})
_model, provider, _base_url = cfg.resolve_model_provider("gpt-5.5")
assert provider == "openai-api"
def test_model_with_provider_context_preserves_openai_api(self, monkeypatch):
monkeypatch.setattr(cfg, "cfg", {
"model": {"provider": "openai-api", "default": "gpt-5.5"},
})
result = cfg.model_with_provider_context("gpt-5.5", "openai-api")
assert "openai" not in result or "openai-api" in result
class TestOpenaiApiEnvDetection:
"""OPENAI_API_KEY env detection must surface `openai-api`, not a bare `openai`
the agent registry can't resolve (#3443 detection-side, Codex follow-up)."""
def test_openai_api_key_detects_openai_api_not_bare_openai(self):
import inspect
src = inspect.getsource(cfg)
# The env-detection branch for OPENAI_API_KEY must add "openai-api".
assert 'detected_providers.add("openai-api")' in src
# And must NOT add a bare "openai" (no such slug in the agent registry).
assert 'detected_providers.add("openai")\n' not in src