The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(portal): name the managed image partner only for the managed selection
kshitijk4poorabd694a65bef
diff --git a/hermes_cli/nous_subscription.py b/hermes_cli/nous_subscription.pyindex 9b79e44ce2e..4f46b1288b7 100644--- a/hermes_cli/nous_subscription.py+++ b/hermes_cli/nous_subscription.py@@ -46,7 +46,7 @@ _FEATURES: Dict[str, _FeatureSpec] = {("PARALLEL_API_KEY", "TAVILY_API_KEY", "PERPLEXITY_API_KEY", "FIRECRAWL_API_KEY", "FIRECRAWL_API_URL"),),"image_gen": _FeatureSpec(- "Image generation", True, "fal", "fal-queue", ("image_gen", "provider"), "Image generation (FAL)", "FAL key",+ "Image generation", True, "fal", "fal-queue", ("image_gen", "provider"), "Image generation", "FAL key",),"video_gen": _FeatureSpec("Video generation", False, "fal-video", "fal-queue", ("video_gen", "provider"), "Video generation (FAL)", "FAL key",@@ -285,31 +285,25 @@ def _web_feature(web_cfg: Dict[str, object], tool_enabled: bool, managed: bool,)-# 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_partner(config: Dict[str, object]) -> Optional[str]:+ """Partner that serves the managed image selection (``"FAL"``, ``"Krea"`` or ``"Nous Portal"``),+ decided by the stored ``image_gen.model``; ``None`` when a direct vendor is selected, since the+ stored model then belongs to that vendor, not to a gateway."""+ from tools.image_generation_managed import FAL, KREA, PORTAL, managed_backend_for_model--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"))+ section = _section(config, "image_gen")+ if _selected_provider(section, "provider") not in (None, "nous"):+ return None+ return {FAL: "FAL", KREA: "Krea", PORTAL: "Nous Portal"}[managed_backend_for_model(section.get("model"))]-def _fal_feature(- key: str, tool_enabled: bool, direct: bool, managed: bool, selected: Optional[str], image_gateway: str,-) -> NousFeatureState:+def _fal_feature(key: str, tool_enabled: bool, direct: bool, managed: bool, selected: Optional[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 = ""+ label = "Nous Subscription" if (fal_managed or selected == "nous") else ""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,@@ -442,17 +436,12 @@ 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(image_probe_gateway if key == "image_gen" else spec.gateway)+ managed_tools_flag and is_managed_tool_gateway_ready(spec.gateway)and account_info.tool_gateway_entitled_for(spec.coverage)and (selected.get(key) is None or use_gateway.get(key, False)))@@ -463,7 +452,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], image_gateway)+ return _fal_feature(key, enabled[key], fal_configured and not use_gateway[key], managed[key], selected[key])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 4f3b5ddb5c8..e3a05f734e7 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"), # printed partner follows the stored image_gen.model+ ("image_gen", "Image generation", "FAL"),("tts", "Text-to-speech", "OpenAI TTS"),("browser", "Browser automation", "Browser Use"),("modal", "Cloud terminal", "Modal"),@@ -104,9 +104,7 @@ def _cmd_open(args) -> int:def _cmd_tools(args) -> int:"""List the Tool Gateway catalog + current routing."""- from hermes_cli.nous_subscription import (- _MANAGED_IMAGE_GATEWAY_LABELS, _managed_image_gateway, get_nous_subscription_features,- )+ from hermes_cli.nous_subscription import get_nous_subscription_features, managed_image_partnerconfig = load_config() or {}try:@@ -120,11 +118,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)]+ # The managed image row routes by the stored model: FAL, Krea or Nous Portal.+ partners = {"image_gen": managed_image_partner(config)}label_width = max(len(label) for _, label, _ in _CATALOG)for key, label, partner in _CATALOG:- if key == "image_gen":- partner = image_partner+ partner = partners.get(key) or 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 25ec2e79ca4..88688746ae0 100644--- a/tests/hermes_cli/test_nous_subscription.py+++ b/tests/hermes_cli/test_nous_subscription.py@@ -210,38 +210,18 @@ def test_logged_in_entitled_account_yields_a_state_for_every_feature(monkeypatch@pytest.mark.parametrize(- "model, expected_label, probes_krea",+ "image_cfg, partner",[- ("krea-2-medium", "Nous Subscription (Krea)", True),- (FAL_DEFAULT_MODEL, "Nous Subscription (FAL)", False),- ("openai/gpt-image-2", "Nous Subscription (Nous Portal)", False),+ ({"provider": "nous", "model": "krea-2-medium"}, "Krea"),+ ({"model": FAL_DEFAULT_MODEL}, "FAL"),+ ({"provider": "nous", "model": "openai/gpt-image-2"}, "Nous Portal"),+ ({"provider": "openai", "model": "gpt-image-2"}, None),],)-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_managed_image_partner_follows_the_stored_model(image_cfg, partner):+ """One managed image row, three gateways: the stored image_gen.model names the partner; a direct+ vendor selection owns its model id, so no gateway partner is claimed for it."""+ assert ns.managed_image_partner({"image_gen": image_cfg}) == partnerdef test_prompt_enable_tool_gateway_pool_offers_covered_tools_only(monkeypatch):