The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(status): name the gateway behind the managed image selection instead of assuming FAL
Mariano Nicolini5171bcf0cad2
diff --git a/hermes_cli/nous_subscription.py b/hermes_cli/nous_subscription.pyindex 505c924bb73..9b79e44ce2e 100644--- a/hermes_cli/nous_subscription.py+++ b/hermes_cli/nous_subscription.py@@ -285,13 +285,31 @@ def _web_feature(web_cfg: Dict[str, object], tool_enabled: bool, managed: bool,)-def _fal_feature(key: str, tool_enabled: bool, direct: bool, managed: bool, selected: Optional[str]) -> NousFeatureState:+# Gateway behind the managed image selection (managed_backend_for_model) -> partner name shown in status.+_MANAGED_IMAGE_GATEWAY_LABELS = {"fal": "FAL", "krea": "Krea", "portal": "Nous Portal"}+++def _managed_image_gateway(config: Dict[str, object]) -> str:+ """``"fal"``, ``"krea"`` or ``"portal"``: the gateway that serves the stored ``image_gen.model``+ under the managed selection."""+ from tools.image_generation_managed import managed_backend_for_model++ return managed_backend_for_model(_section(config, "image_gen").get("model"))+++def _fal_feature(+ key: str, tool_enabled: bool, direct: bool, managed: bool, selected: Optional[str], image_gateway: str,+) -> NousFeatureState:# image_gen / video_gen: same FAL_KEY, independently gated managed availability.fal_managed = tool_enabled and managed and not directif selected not in (None, "nous") or (selected is None and direct):label = "FAL"+ elif fal_managed or selected == "nous":+ label = "Nous Subscription"+ if key == "image_gen":+ label = f"Nous Subscription ({_MANAGED_IMAGE_GATEWAY_LABELS[image_gateway]})"else:- label = "Nous Subscription" if (fal_managed or selected == "nous") else ""+ label = ""return _state(key, available=bool(managed or direct), active=bool(tool_enabled and (fal_managed or direct)),managed_by_nous=fal_managed, toolset_enabled=tool_enabled, current_provider=label,@@ -424,12 +442,17 @@ def get_nous_subscription_features(config: Optional[Dict[str, object]] = None, *for key, (section_key, field) in _GATEWAY_SECTION_FIELDS.items()}use_gateway = {key: value == "nous" for key, value in selected.items()}+ image_gateway = _managed_image_gateway(config)+ # Krea has its own tool-gateway host to probe. Portal image models are served by the inference+ # API, not a tool-gateway host, so the fal-queue probe stands in for them.+ image_probe_gateway = "krea" if image_gateway == "krea" else _FEATURES["image_gen"].gateway# Managed availability per feature. A stored VENDOR selection pins the category to direct# credentials — managed availability must not light it up (the runtime errors, not reroutes).# Features without a config selection field (modal) have no pin and read as unselected.managed = {key: (- managed_tools_flag and is_managed_tool_gateway_ready(spec.gateway)+ managed_tools_flag+ and is_managed_tool_gateway_ready(image_probe_gateway if key == "image_gen" else spec.gateway)and account_info.tool_gateway_entitled_for(spec.coverage)and (selected.get(key) is None or use_gateway.get(key, False)))@@ -440,7 +463,7 @@ def get_nous_subscription_features(config: Optional[Dict[str, object]] = None, *tts, stt = _audio_features(_section(config, "tts"), _section(config, "stt"), enabled["tts"], managed, selected, use_gateway)def _fal(key: str) -> NousFeatureState:- return _fal_feature(key, enabled[key], fal_configured and not use_gateway[key], managed[key], selected[key])+ return _fal_feature(key, enabled[key], fal_configured and not use_gateway[key], managed[key], selected[key], image_gateway)features = { # insertion order == _FEATURE_ORDER"web": _web_feature(_section(config, "web"), enabled["web"], managed["web"], use_gateway["web"], direct_firecrawl),diff --git a/hermes_cli/portal_cli.py b/hermes_cli/portal_cli.pyindex f5feedecf53..4f3b5ddb5c8 100644--- a/hermes_cli/portal_cli.py+++ b/hermes_cli/portal_cli.py@@ -13,7 +13,7 @@ DOCS_URL = "https://hermes-agent.nousresearch.com/docs/user-guide/features/tool-# Static `portal tools` catalog — the partners Tool Gateway routes to today: (key, label, partner)._CATALOG = [("web", "Web search & extract", "Nous-managed"),- ("image_gen", "Image generation", "FAL"),+ ("image_gen", "Image generation", "FAL"), # printed partner follows the stored image_gen.model("tts", "Text-to-speech", "OpenAI TTS"),("browser", "Browser automation", "Browser Use"),("modal", "Cloud terminal", "Modal"),@@ -104,7 +104,9 @@ def _cmd_open(args) -> int:def _cmd_tools(args) -> int:"""List the Tool Gateway catalog + current routing."""- from hermes_cli.nous_subscription import get_nous_subscription_features+ from hermes_cli.nous_subscription import (+ _MANAGED_IMAGE_GATEWAY_LABELS, _managed_image_gateway, get_nous_subscription_features,+ )config = load_config() or {}try:@@ -118,8 +120,11 @@ def _cmd_tools(args) -> int:print(color(" Not logged into Nous Portal — sign in with `hermes portal`.", Colors.YELLOW))print()+ image_partner = _MANAGED_IMAGE_GATEWAY_LABELS[_managed_image_gateway(config)]label_width = max(len(label) for _, label, _ in _CATALOG)for key, label, partner in _CATALOG:+ if key == "image_gen":+ partner = image_partnerfeat = features.features.get(key)state = color("unknown", Colors.DIM) if feat is None else _feature_state(feat, via_nous="✓ via Nous Portal")print(f" {label:<{label_width}} partner: {partner:<14} {state}")diff --git a/tests/hermes_cli/test_nous_subscription.py b/tests/hermes_cli/test_nous_subscription.pyindex 500397850a0..25ec2e79ca4 100644--- a/tests/hermes_cli/test_nous_subscription.py+++ b/tests/hermes_cli/test_nous_subscription.py@@ -3,10 +3,13 @@import shutilimport sys+import pytest+from hermes_cli.nous_account import NousPortalAccountInfo, NousToolAccessInfofrom hermes_cli import nous_subscription as nsfrom tools import tool_backend_helpersfrom tools import browser_tool_install as bt_install+from tools.image_generation_catalog import DEFAULT_MODEL as FAL_DEFAULT_MODEL_POOL_COVERAGE = {@@ -206,6 +209,41 @@ def test_logged_in_entitled_account_yields_a_state_for_every_feature(monkeypatchassert result.modal.available is True # entitled + gateway ready → managed modal is offered+ "model, expected_label, probes_krea",+ [+ ("krea-2-medium", "Nous Subscription (Krea)", True),+ (FAL_DEFAULT_MODEL, "Nous Subscription (FAL)", False),+ ("openai/gpt-image-2", "Nous Subscription (Nous Portal)", False),+ ],+)+def test_managed_image_label_and_probe_follow_the_stored_model(monkeypatch, model, expected_label, probes_krea):+ """One managed image row, three gateways: the status label names the gateway the stored+ image_gen.model routes to, and only a Krea model probes the krea host for readiness (Portal+ models have no tool-gateway host, so they stay on fal-queue). Video keeps its plain label."""+ probed = []++ def _record_probe(gateway):+ probed.append(gateway)+ return True++ monkeypatch.setattr(ns, "get_nous_portal_account_info", lambda **kw: _account(logged_in=True, paid=True))+ monkeypatch.setattr(ns, "is_managed_tool_gateway_ready", _record_probe)+ monkeypatch.setattr(ns, "get_env_value", lambda name: "")+ monkeypatch.setattr(ns, "fal_key_is_configured", lambda: False)+ monkeypatch.setattr(ns, "_toolset_enabled", lambda config, key: key in ("image_gen", "video_gen"))+ monkeypatch.setattr(ns, "_has_agent_browser", lambda: False)+ monkeypatch.setattr(ns, "resolve_openai_audio_api_key", lambda: "")+ monkeypatch.setattr(ns, "has_direct_modal_credentials", lambda: False)++ config = {"model": {"provider": "nous"}, "image_gen": {"provider": "nous", "model": model}}+ features = ns.get_nous_subscription_features(config)++ assert features.image_gen.current_provider == expected_label+ assert ("krea" in probed) is probes_krea+ assert features.video_gen.current_provider == "Nous Subscription"++def test_prompt_enable_tool_gateway_pool_offers_covered_tools_only(monkeypatch):"""Pool user's checklist lists web/image/tts/browser and never video."""monkeypatch.setattr(ns, "get_nous_portal_account_info", lambda **kw: _pool_account())