The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): persist one provider string per picker row; mirror strict routing in status
Tekniumb10c5a8084b4
diff --git a/hermes_cli/nous_subscription.py b/hermes_cli/nous_subscription.pyindex 5289cabce07..882956fe311 100644--- a/hermes_cli/nous_subscription.py+++ b/hermes_cli/nous_subscription.py@@ -54,6 +54,26 @@ def _uses_gateway(section: object) -> bool:return is_truthy_value(section.get("use_gateway"), default=False)+def _selected_provider(section: object, name_key: str = "provider") -> Optional[str]:+ """Return the stored provider string for a config section dict.++ Mirrors :func:`tools.tool_backend_helpers.read_selection`'s semantics on+ an in-memory section dict: ``"nous"`` for the managed selection (stored+ ``nous`` value or legacy ``use_gateway: true``), a vendor name for BYOK+ picks, or ``None`` when no selection is stored. Keeping this in lockstep+ with the runtime resolver is what stops ``hermes status`` from lying.+ """+ if not isinstance(section, dict):+ return None+ if is_truthy_value(section.get("use_gateway"), default=False):+ return "nous"+ value = section.get(name_key)+ if value is None:+ return None+ name = str(value).strip().lower()+ return name or None++@dataclass(frozen=True)class NousFeatureState:key: str@@ -315,11 +335,14 @@ def _resolve_browser_feature_state(on the latter, or setup/status advertise a browser that fails on first usewhen Chromium is missing."""- if direct_camofox:- return "camofox", True, bool(browser_tool_enabled), False-if browser_provider_explicit:current_provider = browser_provider or "local"+ if current_provider == "camofox":+ # Camofox is now a stored selection (browser.cloud_provider:+ # camofox); CAMOFOX_URL is only the server address.+ available = bool(direct_camofox)+ active = bool(browser_tool_enabled and available)+ return current_provider, available, active, Falseif current_provider == "browserbase":available = bool(browser_local_available and direct_browserbase)active = bool(browser_tool_enabled and available)@@ -347,6 +370,11 @@ def _resolve_browser_feature_state(active = bool(browser_tool_enabled and available)return current_provider, available, active, False+ # Never-configured autodetect: CAMOFOX_URL keeps activating Camofox+ # exactly as before when no cloud_provider selection was ever stored.+ if direct_camofox:+ return "camofox", True, bool(browser_tool_enabled), False+if managed_browser_available or direct_browser_use:available = bool(browser_local_available)managed = bool(@@ -435,17 +463,48 @@ def get_nous_subscription_features(terminal_cfg.get("modal_mode"))- # use_gateway flags — when True, the user explicitly opted into the- # Tool Gateway via `hermes model`, so direct credentials should NOT- # prevent gateway routing.- web_use_gateway = _uses_gateway(web_cfg)- tts_use_gateway = _uses_gateway(tts_cfg)- stt_use_gateway = _uses_gateway(stt_cfg)- browser_use_gateway = _uses_gateway(browser_cfg)+ # Stored selections (strict model): one provider string per category.+ # "nous" (stored value or legacy use_gateway: true) = managed gateway;+ # vendor name = that vendor direct; None = never configured (autodetect).image_gen_cfg = config.get("image_gen") if isinstance(config.get("image_gen"), dict) else {}- image_use_gateway = _uses_gateway(image_gen_cfg)video_gen_cfg = config.get("video_gen") if isinstance(config.get("video_gen"), dict) else {}- video_use_gateway = _uses_gateway(video_gen_cfg)+ web_selected = _selected_provider(web_cfg, "backend")+ tts_selected = _selected_provider(tts_cfg)+ stt_selected = _selected_provider(stt_cfg)+ browser_selected = _selected_provider(browser_cfg, "cloud_provider")+ image_selected = _selected_provider(image_gen_cfg)+ video_selected = _selected_provider(video_gen_cfg)++ # Same seeded-value shim as tools.tool_backend_helpers.read_selection:+ # legacy DEFAULT_CONFIG seeded ``stt.provider: local`` on every install,+ # so that exact value with no picker-written use_gateway key is treated+ # as never-configured.+ if (+ stt_selected == "local"+ and isinstance(stt_cfg, dict)+ and "use_gateway" not in stt_cfg+ ):+ stt_selected = None++ # Managed selection flags (replace the legacy use_gateway reads —+ # use_gateway is now interpreted only inside _selected_provider).+ web_use_gateway = web_selected == "nous"+ tts_use_gateway = tts_selected == "nous"+ stt_use_gateway = stt_selected == "nous"+ browser_use_gateway = browser_selected == "nous"+ image_use_gateway = image_selected == "nous"+ video_use_gateway = video_selected == "nous"++ # The "nous" selection is serviced by a concrete vendor implementation —+ # normalize the current-provider labels so downstream vendor checks hold.+ if web_backend == "nous" or web_use_gateway:+ web_backend = "firecrawl"+ if tts_provider == "nous" or tts_use_gateway:+ tts_provider = "openai"+ if stt_provider == "nous" or stt_use_gateway:+ stt_provider = "openai"+ if browser_provider == "nous" or browser_use_gateway:+ browser_provider = "browser-use"direct_exa = bool(get_env_value("EXA_API_KEY"))direct_firecrawl = bool(get_env_value("FIRECRAWL_API_KEY") or get_env_value("FIRECRAWL_API_URL"))@@ -549,6 +608,27 @@ def get_nous_subscription_features(managed_enabled=managed_tools_flag,)+ # Strict selection: a stored VENDOR selection pins the category to direct+ # credentials — managed availability must not light the feature up (the+ # runtime will error, not reroute), and camofox/local selections must not+ # be pre-empted by env credentials for other providers.+ if web_selected is not None and not web_use_gateway:+ managed_web_available = False+ if image_selected is not None and not image_use_gateway:+ managed_image_available = False+ if video_selected is not None and not video_use_gateway:+ managed_video_available = False+ if tts_selected is not None and not tts_use_gateway:+ managed_tts_available = False+ if stt_selected is not None and not stt_use_gateway:+ managed_stt_available = False+ if browser_selected is not None and not browser_use_gateway:+ managed_browser_available = False+ if browser_selected is not None and browser_selected != "camofox":+ # CAMOFOX_URL is the server address, not a selection: an explicit+ # different browser choice wins over the env var.+ direct_camofox = False+web_managed = web_backend == "firecrawl" and managed_web_available and not direct_firecrawlweb_active = bool(web_tool_enabled@@ -664,17 +744,10 @@ def get_nous_subscription_features(modal_active = Falsemodal_direct_override = False- tts_explicit_configured = False- raw_tts_cfg = config.get("tts")- if isinstance(raw_tts_cfg, dict) and "provider" in raw_tts_cfg:- tts_explicit_configured = tts_provider not in {"", "edge"}-- # STT considers any non-default provider explicit. "local" is the- # DEFAULT_CONFIG seed, so seeing it doesn't mean the user picked it.- stt_explicit_configured = False- raw_stt_cfg = config.get("stt")- if isinstance(raw_stt_cfg, dict) and "provider" in raw_stt_cfg:- stt_explicit_configured = stt_provider not in {"", "local"}+ # Explicit-configured mirrors the stored selections computed above so+ # status/picker markers stay in lockstep with runtime dispatch.+ tts_explicit_configured = tts_selected is not None and tts_selected != "edge"+ stt_explicit_configured = stt_selected is not Nonefeatures = {"web": NousFeatureState(@@ -698,8 +771,8 @@ def get_nous_subscription_features(managed_by_nous=image_managed,direct_override=image_active and not image_managed,toolset_enabled=image_tool_enabled,- current_provider="FAL" if direct_fal else ("Nous Subscription" if image_managed else ""),- explicit_configured=direct_fal,+ current_provider="FAL" if (image_selected not in (None, "nous") or (image_selected is None and direct_fal)) else ("Nous Subscription" if (image_managed or image_use_gateway) else ""),+ explicit_configured=image_selected is not None or direct_fal,),"video_gen": NousFeatureState(key="video_gen",@@ -710,8 +783,8 @@ def get_nous_subscription_features(managed_by_nous=video_managed,direct_override=video_active and not video_managed,toolset_enabled=video_tool_enabled,- current_provider="FAL" if direct_fal_video else ("Nous Subscription" if video_managed else ""),- explicit_configured=direct_fal_video,+ current_provider="FAL" if (video_selected not in (None, "nous") or (video_selected is None and direct_fal_video)) else ("Nous Subscription" if (video_managed or video_use_gateway) else ""),+ explicit_configured=video_selected is not None or direct_fal_video,),"tts": NousFeatureState(key="tts",@@ -823,24 +896,26 @@ def apply_nous_managed_defaults(or get_env_value("FIRECRAWL_API_KEY")or get_env_value("FIRECRAWL_API_URL")):- web_cfg["backend"] = "firecrawl"+ web_cfg["backend"] = "nous"+ web_cfg.pop("use_gateway", None)changed.add("web")if "tts" in selected_toolsets and not features.tts.explicit_configured and not (resolve_openai_audio_api_key()or get_env_value("ELEVENLABS_API_KEY")):- tts_cfg["provider"] = "openai"+ tts_cfg["provider"] = "nous"+ tts_cfg.pop("use_gateway", None)changed.add("tts")# STT: same pattern as TTS. The DEFAULT_CONFIG seed is "local"# (requires `pip install faster-whisper`); for Nous subscribers we- # flip it to "openai" so the managed audio gateway handles transcription- # via the same auth as TTS. Skipped when the user has explicitly- # configured STT, has direct credentials for a non-managed provider,- # has a working local backend (faster-whisper installed or a custom- # local command — strong intent signal that "local" was a choice, not- # just the DEFAULT_CONFIG seed), or isn't entitled to the managed+ # flip it to the managed selection so the managed audio gateway handles+ # transcription via the same auth as TTS. Skipped when the user has+ # explicitly configured STT, has direct credentials for a non-managed+ # provider, has a working local backend (faster-whisper installed or a+ # custom local command — strong intent signal that "local" was a choice,+ # not just the DEFAULT_CONFIG seed), or isn't entitled to the managed# "openai-audio" category (flipping would point at a gateway that# refuses them, silently breaking voice transcription).if (@@ -854,14 +929,16 @@ def apply_nous_managed_defaults(and features.account_info is not Noneand features.account_info.tool_gateway_entitled_for("openai-audio")):- stt_cfg["provider"] = "openai"+ stt_cfg["provider"] = "nous"+ stt_cfg.pop("use_gateway", None)changed.add("stt")if "browser" in selected_toolsets and not features.browser.explicit_configured and not (get_env_value("BROWSER_USE_API_KEY")or get_env_value("BROWSERBASE_API_KEY")):- browser_cfg["cloud_provider"] = "browser-use"+ browser_cfg["cloud_provider"] = "nous"+ browser_cfg.pop("use_gateway", None)changed.add("browser")if "image_gen" in selected_toolsets and not fal_key_is_configured():@@ -869,7 +946,8 @@ def apply_nous_managed_defaults(if not isinstance(image_cfg, dict):image_cfg = {}config["image_gen"] = image_cfg- image_cfg["use_gateway"] = True+ image_cfg["provider"] = "nous"+ image_cfg.pop("use_gateway", None)changed.add("image_gen")# Video gen is not funded by the free tool pool, so only wire managed video@@ -883,8 +961,8 @@ def apply_nous_managed_defaults(if not isinstance(video_cfg, dict):video_cfg = {}config["video_gen"] = video_cfg- video_cfg["provider"] = "fal"- video_cfg["use_gateway"] = True+ video_cfg["provider"] = "nous"+ video_cfg.pop("use_gateway", None)changed.add("video_gen")return changed@@ -1050,23 +1128,23 @@ def apply_gateway_defaults(config["browser"] = browser_cfgif "web" in tool_keys:- web_cfg["backend"] = "firecrawl"- web_cfg["use_gateway"] = True+ web_cfg["backend"] = "nous"+ web_cfg.pop("use_gateway", None)changed.add("web")if "tts" in tool_keys:- tts_cfg["provider"] = "openai"- tts_cfg["use_gateway"] = True+ tts_cfg["provider"] = "nous"+ tts_cfg.pop("use_gateway", None)changed.add("tts")if "stt" in tool_keys:- stt_cfg["provider"] = "openai"- stt_cfg["use_gateway"] = True+ stt_cfg["provider"] = "nous"+ stt_cfg.pop("use_gateway", None)changed.add("stt")if "browser" in tool_keys:- browser_cfg["cloud_provider"] = "browser-use"- browser_cfg["use_gateway"] = True+ browser_cfg["cloud_provider"] = "nous"+ browser_cfg.pop("use_gateway", None)changed.add("browser")if "image_gen" in tool_keys:@@ -1074,7 +1152,8 @@ def apply_gateway_defaults(if not isinstance(image_cfg, dict):image_cfg = {}config["image_gen"] = image_cfg- image_cfg["use_gateway"] = True+ image_cfg["provider"] = "nous"+ image_cfg.pop("use_gateway", None)changed.add("image_gen")if "video_gen" in tool_keys:@@ -1082,8 +1161,8 @@ def apply_gateway_defaults(if not isinstance(video_cfg, dict):video_cfg = {}config["video_gen"] = video_cfg- video_cfg["provider"] = "fal"- video_cfg["use_gateway"] = True+ video_cfg["provider"] = "nous"+ video_cfg.pop("use_gateway", None)changed.add("video_gen")return changeddiff --git a/hermes_cli/tools_config.py b/hermes_cli/tools_config.pyindex 599ec3abf1e..a724b4888f2 100644--- a/hermes_cli/tools_config.py+++ b/hermes_cli/tools_config.py@@ -31,7 +31,7 @@ from hermes_cli.nous_subscription import (get_nous_subscription_features,)from hermes_cli.nous_account import format_nous_portal_entitlement_message-from tools.tool_backend_helpers import fal_key_is_configured+from tools.tool_backend_helpers import NOUS_MANAGED_PROVIDER, fal_key_is_configuredfrom utils import base_url_hostname, is_truthy_valuelogger = logging.getLogger(__name__)@@ -3823,39 +3823,55 @@ def _is_provider_active(image_cfg = config.get("image_gen", {})if isinstance(image_cfg, dict):configured_provider = image_cfg.get("provider")- if configured_provider not in {None, "", "fal"}:+ if configured_provider not in {None, "", "fal", NOUS_MANAGED_PROVIDER}:return False- if image_cfg.get("use_gateway") is not None and not is_truthy_value(image_cfg.get("use_gateway"), default=False):+ if (+ configured_provider != NOUS_MANAGED_PROVIDER+ and image_cfg.get("use_gateway") is not None+ and not is_truthy_value(image_cfg.get("use_gateway"), default=False)+ ):return Falsereturn feature.managed_by_nousif managed_feature == "video_gen":video_cfg = config.get("video_gen", {})if isinstance(video_cfg, dict):configured_provider = video_cfg.get("provider")- if configured_provider not in {None, "", "fal"}:+ if configured_provider not in {None, "", "fal", NOUS_MANAGED_PROVIDER}:return False- if video_cfg.get("use_gateway") is not None and not is_truthy_value(video_cfg.get("use_gateway"), default=False):+ if (+ configured_provider != NOUS_MANAGED_PROVIDER+ and video_cfg.get("use_gateway") is not None+ and not is_truthy_value(video_cfg.get("use_gateway"), default=False)+ ):return Falsereturn feature.managed_by_nousif provider.get("tts_provider"):return (feature.managed_by_nous- and cfg_get(config, "tts", "provider") == provider["tts_provider"]+ and cfg_get(config, "tts", "provider")+ in {provider["tts_provider"], NOUS_MANAGED_PROVIDER})if provider.get("stt_provider"):return (feature.managed_by_nous- and cfg_get(config, "stt", "provider") == provider["stt_provider"]+ and cfg_get(config, "stt", "provider")+ in {provider["stt_provider"], NOUS_MANAGED_PROVIDER})if "browser_provider" in provider:# Browser Use mode is a driver on top of the provider (it attaches# to the provider's CDP endpoint), so the provider row stays# active alongside the Browser Use row.current = cfg_get(config, "browser", "cloud_provider")- return feature.managed_by_nous and provider["browser_provider"] == current+ return feature.managed_by_nous and current in {+ provider["browser_provider"],+ NOUS_MANAGED_PROVIDER,+ }if provider.get("web_backend"):current = cfg_get(config, "web", "backend")- return feature.managed_by_nous and current == provider["web_backend"]+ return feature.managed_by_nous and current in {+ provider["web_backend"],+ NOUS_MANAGED_PROVIDER,+ }return feature.managed_by_nousif provider.get("tts_provider"):@@ -4168,20 +4184,19 @@ def _configure_xai_imagine_storage(section_name: str, config: dict) -> None:def _select_plugin_image_gen_provider(plugin_name: str, config: dict, *, use_gateway: bool = False) -> None:"""Persist a plugin-backed image generation provider selection.- ``use_gateway`` mirrors :func:`_select_plugin_video_gen_provider`: a- provider picked through the Nous-managed flow must keep routing through- the gateway. Hardcoding ``False`` here silently flipped Nous-managed FAL- picks onto the user's personal FAL_KEY — _write_provider_config sets- ``image_gen.use_gateway = True`` for a managed pick, and this function- runs AFTER it, so the hardcoded value clobbered the managed flag.+ ``use_gateway=True`` marks a provider picked through the Nous-managed+ flow: the stored selection becomes ``image_gen.provider: nous`` (the+ single provider string the runtime switches on). BYOK picks store the+ plugin name. Any legacy ``use_gateway`` key is removed so old-config+ read-time shims cannot override the fresh selection."""img_cfg = config.setdefault("image_gen", {})if not isinstance(img_cfg, dict):img_cfg = {}config["image_gen"] = img_cfg- img_cfg["provider"] = plugin_name- img_cfg["use_gateway"] = use_gateway- _print_success(f" image_gen.provider set to: {plugin_name}")+ img_cfg["provider"] = NOUS_MANAGED_PROVIDER if use_gateway else plugin_name+ img_cfg.pop("use_gateway", None)+ _print_success(f" image_gen.provider set to: {img_cfg['provider']}")_configure_imagegen_model_for_plugin(plugin_name, config)if plugin_name == "xai":_configure_xai_imagine_storage("image_gen", config)@@ -4321,14 +4336,19 @@ def _configure_stt_model(stt_provider: str, config: dict) -> None:def _select_plugin_video_gen_provider(plugin_name: str, config: dict, *, use_gateway: bool = False) -> None:- """Persist a plugin-backed video generation provider selection."""+ """Persist a plugin-backed video generation provider selection.++ Mirrors :func:`_select_plugin_image_gen_provider`: managed picks store+ ``video_gen.provider: nous``; BYOK picks store the plugin name; any+ legacy ``use_gateway`` key is removed.+ """vid_cfg = config.setdefault("video_gen", {})if not isinstance(vid_cfg, dict):vid_cfg = {}config["video_gen"] = vid_cfg- vid_cfg["provider"] = plugin_name- vid_cfg["use_gateway"] = use_gateway- _print_success(f" video_gen.provider set to: {plugin_name}")+ vid_cfg["provider"] = NOUS_MANAGED_PROVIDER if use_gateway else plugin_name+ vid_cfg.pop("use_gateway", None)+ _print_success(f" video_gen.provider set to: {vid_cfg['provider']}")_configure_videogen_model_for_plugin(plugin_name, config)if plugin_name == "xai":_configure_xai_imagine_storage("video_gen", config)@@ -4339,32 +4359,45 @@ def _write_provider_config(provider: dict, config: dict, *, managed_feature) ->This is the pure, non-interactive core of :func:`_configure_provider` —it writes ``tts.provider`` / ``browser.cloud_provider`` / ``web.backend``- and the ``use_gateway`` flags based on the provider's markers, but does- NOT prompt for env vars, run post-setup hooks, gate on Nous auth, or run- interactive model pickers. Both the CLI configurator and the desktop GUI- ``PUT .../provider`` endpoint call through here so there is one code path.+ based on the provider's markers, but does NOT prompt for env vars, run+ post-setup hooks, gate on Nous auth, or run interactive model pickers.+ Both the CLI configurator and the desktop GUI ``PUT .../provider``+ endpoint call through here so there is one code path.++ Selection model: every row writes exactly ONE provider string per+ category. Managed "Nous Subscription" rows write ``nous``; BYOK rows+ write the vendor name. ``use_gateway`` is no longer written — a fresh+ pick removes any legacy key from the touched section so the read-time+ legacy shim (use_gateway: true ⇒ nous) cannot override the new choice."""+ def _set_selection(section_key: str, name_key: str, vendor_value) -> None:+ section = config.setdefault(section_key, {})+ if not isinstance(section, dict):+ section = {}+ config[section_key] = section+ section[name_key] = (+ NOUS_MANAGED_PROVIDER if managed_feature else vendor_value+ )+ section.pop("use_gateway", None)+# Set TTS provider in config if applicableif provider.get("tts_provider"):- tts_cfg = config.setdefault("tts", {})- tts_cfg["provider"] = provider["tts_provider"]- tts_cfg["use_gateway"] = bool(managed_feature)+ _set_selection("tts", "provider", provider["tts_provider"])# Set STT provider in config if applicableif provider.get("stt_provider"):- stt_cfg = config.setdefault("stt", {})- stt_cfg["provider"] = provider["stt_provider"]- stt_cfg["use_gateway"] = bool(managed_feature)+ _set_selection("stt", "provider", provider["stt_provider"])# Set browser cloud provider in config if applicableif "browser_provider" in provider:bp = provider["browser_provider"]browser_cfg = config.setdefault("browser", {})- if bp:- browser_cfg["cloud_provider"] = bp- # Browser Use mode (browser.backend) composes with the provider —- # switching providers keeps the driver choice intact.- browser_cfg["use_gateway"] = bool(managed_feature)+ if bp or managed_feature:+ # Browser Use mode (browser.backend) composes with the provider —+ # switching providers keeps the driver choice intact.+ _set_selection("browser", "cloud_provider", bp)+ else:+ browser_cfg.pop("use_gateway", None)if provider.get("browser_backend"):browser_cfg = config.setdefault("browser", {})@@ -4372,28 +4405,51 @@ def _write_provider_config(provider: dict, config: dict, *, managed_feature) -># Set web search backend in config if applicableif provider.get("web_backend"):- web_cfg = config.setdefault("web", {})- web_cfg["backend"] = provider["web_backend"]- web_cfg["use_gateway"] = bool(managed_feature)+ _set_selection("web", "backend", provider["web_backend"])# Set computer_use backend in config if applicableif provider.get("computer_use_backend"):cu_cfg = config.setdefault("computer_use", {})cu_cfg["backend"] = provider["computer_use_backend"]- # For tools without a specific config key (e.g. image_gen), still- # track use_gateway so the runtime knows the user's intent.+ # Managed rows for categories without a marker handled above (e.g. the+ # image_gen/video_gen "Nous Subscription" rows carry only+ # managed_nous_feature) still persist the "nous" selection.if managed_feature and managed_feature not in {"web", "tts", "stt", "browser"}:- config.setdefault(managed_feature, {})["use_gateway"] = True+ section = config.setdefault(managed_feature, {})+ if isinstance(section, dict):+ section["provider"] = NOUS_MANAGED_PROVIDER+ section.pop("use_gateway", None)elif not managed_feature:- # User picked a non-gateway provider — find which category this- # belongs to and clear use_gateway if it was previously set.- for cat_key, cat in TOOL_CATEGORIES.items():- if provider in cat.get("providers", []):- section = config.get(cat_key)- if isinstance(section, dict) and section.get("use_gateway"):- section["use_gateway"] = False- break+ # User picked a non-gateway provider — clear any stale legacy+ # use_gateway key on the category so the read-time shim cannot+ # override the fresh selection. Resolve the category from the+ # provider's own markers first (plugin-injected rows are NOT in+ # TOOL_CATEGORIES' hardcoded provider lists and previously skipped+ # this clear), then fall back to the category-membership walk.+ marker_sections = {+ "tts_provider": "tts",+ "stt_provider": "stt",+ "browser_provider": "browser",+ "web_backend": "web",+ "image_gen_plugin_name": "image_gen",+ "imagegen_backend": "image_gen",+ "video_gen_plugin_name": "video_gen",+ }+ cleared = False+ for marker, section_key in marker_sections.items():+ if provider.get(marker) or marker in provider:+ section = config.get(section_key)+ if isinstance(section, dict):+ section.pop("use_gateway", None)+ cleared = True+ if not cleared:+ for cat_key, cat in TOOL_CATEGORIES.items():+ if provider in cat.get("providers", []):+ section = config.get(cat_key)+ if isinstance(section, dict):+ section.pop("use_gateway", None)+ breakdef apply_provider_selection(ts_key: str, provider_name: str, config: dict) -> None:@@ -4425,15 +4481,17 @@ def apply_provider_selection(ts_key: str, provider_name: str, config: dict) -> N# Plugin-registered image/video gen backends record the provider name in# their own config section. Write that here (without the interactive# model picker the CLI runs afterwards — model choice is a separate GUI- # flow).+ # flow). Managed picks store the "nous" selection.plugin_name = provider.get("image_gen_plugin_name")if plugin_name:img_cfg = config.setdefault("image_gen", {})if not isinstance(img_cfg, dict):img_cfg = {}config["image_gen"] = img_cfg- img_cfg["provider"] = plugin_name- img_cfg["use_gateway"] = bool(managed_feature)+ img_cfg["provider"] = (+ NOUS_MANAGED_PROVIDER if managed_feature else plugin_name+ )+ img_cfg.pop("use_gateway", None)video_plugin = provider.get("video_gen_plugin_name")if video_plugin:@@ -4441,15 +4499,22 @@ def apply_provider_selection(ts_key: str, provider_name: str, config: dict) -> Nif not isinstance(vid_cfg, dict):vid_cfg = {}config["video_gen"] = vid_cfg- vid_cfg["provider"] = video_plugin- vid_cfg["use_gateway"] = bool(managed_feature)+ vid_cfg["provider"] = (+ NOUS_MANAGED_PROVIDER if managed_feature else video_plugin+ )+ vid_cfg.pop("use_gateway", None)- # In-tree FAL imagegen backend: keep image_gen.provider on the legacy- # path (mirrors _configure_provider).- if provider.get("imagegen_backend"):+ # In-tree FAL imagegen backend (BYOK): always persist the explicit+ # ``image_gen.provider: fal`` selection — historically this row could+ # leave the provider key unset, making a deliberate BYOK pick+ # indistinguishable from a never-configured install.+ if provider.get("imagegen_backend") and not managed_feature:img_cfg = config.setdefault("image_gen", {})- if isinstance(img_cfg, dict) and img_cfg.get("provider") not in {None, "", "fal"}:- img_cfg["provider"] = "fal"+ if not isinstance(img_cfg, dict):+ img_cfg = {}+ config["image_gen"] = img_cfg+ img_cfg["provider"] = "fal"+ img_cfg.pop("use_gateway", None)def _configure_provider(@@ -4503,8 +4568,10 @@ def _configure_provider(# Set TTS provider in config if applicableif provider.get("tts_provider"):tts_cfg = config.setdefault("tts", {})- tts_cfg["provider"] = provider["tts_provider"]- tts_cfg["use_gateway"] = bool(managed_feature)+ tts_cfg["provider"] = (+ NOUS_MANAGED_PROVIDER if managed_feature else provider["tts_provider"]+ )+ tts_cfg.pop("use_gateway", None)# Set STT provider in config if applicableif provider.get("stt_provider"):@@ -4552,13 +4619,15 @@ def _configure_provider(backend = provider.get("imagegen_backend")if backend:_configure_imagegen_model(backend, config)- # In-tree FAL is the only non-plugin backend today. Keep- # image_gen.provider clear so the dispatch shim falls through- # to the legacy FAL path.+ # In-tree FAL is the only non-plugin backend today. Persist the+ # explicit selection: "nous" for a managed row, "fal" for BYOK.img_cfg = config.setdefault("image_gen", {})- if isinstance(img_cfg, dict) and img_cfg.get("provider") not in {None, "", "fal"}:- img_cfg["provider"] = "fal"- # STT providers prompt for model selection after provider pick+ if isinstance(img_cfg, dict):+ img_cfg["provider"] = (+ NOUS_MANAGED_PROVIDER if managed_feature else "fal"+ )+ img_cfg.pop("use_gateway", None)+ # STT providers prompt for model selection after backend pick# (skipped for managed rows — the gateway pins the model).if provider.get("stt_provider") and not managed_feature:_configure_stt_model(provider["stt_provider"], config)@@ -4636,8 +4705,11 @@ def _configure_provider(if backend:_configure_imagegen_model(backend, config)img_cfg = config.setdefault("image_gen", {})- if isinstance(img_cfg, dict) and img_cfg.get("provider") not in {None, "", "fal"}:- img_cfg["provider"] = "fal"+ if isinstance(img_cfg, dict):+ img_cfg["provider"] = (+ NOUS_MANAGED_PROVIDER if managed_feature else "fal"+ )+ img_cfg.pop("use_gateway", None)# STT providers prompt for model selection after env vars are in.if provider.get("stt_provider") and not managed_feature:_configure_stt_model(provider["stt_provider"], config)@@ -5091,14 +5163,14 @@ def _reconfigure_provider(if backend == "fal":img_cfg = config.setdefault("image_gen", {})if isinstance(img_cfg, dict):- img_cfg["provider"] = "fal"# A managed (Nous Subscription) row also carries- # imagegen_backend="fal" — the model picker runs AFTER- # _write_provider_config set use_gateway=True, so an- # unconditional False here silently flipped managed- # picks onto the user's personal FAL_KEY (same class- # as fe63353cb, which fixed the plugin-provider path).- img_cfg["use_gateway"] = bool(managed_feature)+ # imagegen_backend="fal" — store the "nous" selection+ # for it, "fal" for BYOK, and drop any legacy+ # use_gateway key.+ img_cfg["provider"] = (+ NOUS_MANAGED_PROVIDER if managed_feature else "fal"+ )+ img_cfg.pop("use_gateway", None)# STT providers prompt for model selection on reconfig too.if provider.get("stt_provider") and not managed_feature:_configure_stt_model(provider["stt_provider"], config)@@ -5140,10 +5212,12 @@ def _reconfigure_provider(if backend == "fal":img_cfg = config.setdefault("image_gen", {})if isinstance(img_cfg, dict):- img_cfg["provider"] = "fal"# Same managed-row guard as the no-env-vars branch above:# never clobber a Nous-managed pick back onto direct keys.- img_cfg["use_gateway"] = bool(managed_feature)+ img_cfg["provider"] = (+ NOUS_MANAGED_PROVIDER if managed_feature else "fal"+ )+ img_cfg.pop("use_gateway", None)# STT providers prompt for model selection on reconfig too.if provider.get("stt_provider") and not managed_feature: