Skip to content

The agent that grows with you

fix(free-tier): a guest kept for connectors never acts as a free-tier login

alt-glitch5ebef93797d3
diff --git a/agent/credential_pool.py b/agent/credential_pool.py
index 9682aedcf62..ce32f09f71b 100644
--- a/agent/credential_pool.py
+++ b/agent/credential_pool.py
@@ -2639,9 +2639,9 @@ def _seed_anthropic_singletons(seed: _Seeder) -> None:
def _seed_nous_singleton(seed: _Seeder, auth_store: dict[str, Any]) -> None:
state, source_path = _load_provider_state_with_source(auth_store, "nous")
- if owned_profile_reads_root_state(auth_store, "nous", source_path):
- # e.g. an agent_key-only row surviving a fork strip/heal
- return
+ from hermes_cli.anon_auth import guest_without_free_tier
+ if guest_without_free_tier(state) or owned_profile_reads_root_state(auth_store, "nous", source_path):
+ return # a guest kept for connectors only; an agent_key-only row surviving a fork strip/heal
has_runtime_material = bool(
isinstance(state, dict)
and (str(state.get("access_token") or "").strip() or str(state.get("agent_key") or "").strip())
diff --git a/hermes_cli/anon_auth.py b/hermes_cli/anon_auth.py
index b1ebbc84a7b..72a84166401 100644
--- a/hermes_cli/anon_auth.py
+++ b/hermes_cli/anon_auth.py
@@ -218,6 +218,12 @@ def has_free_tier_account() -> bool:
return guest_enabled() and has_guest()
+def guest_without_free_tier(state: Any) -> bool:
+ """A guest identity while the free tier is off: it serves connectors and managed tools only, so
+ inference, account and status readers treat the profile as not signed in."""
+ return is_guest_state(state) and not guest_enabled()
+
+
def free_tier_route() -> bool:
from hermes_cli.auth import resolve_provider
return has_free_tier_account() and resolve_provider("auto") == "nous"
@@ -934,7 +940,7 @@ FREE_TIER_AVAILABLE_NOTICE = (
def guest_notice_pending() -> bool:
"""True when a guest identity exists and the one-time availability notice has not been shown."""
state = current_nous_state()
- return is_guest_state(state) and not bool(state.get(GUEST_NOTICE_FLAG))
+ return guest_enabled() and is_guest_state(state) and not bool(state.get(GUEST_NOTICE_FLAG))
def mark_guest_notice_shown() -> bool:
diff --git a/hermes_cli/auth_commands.py b/hermes_cli/auth_commands.py
index 63b9c2acaf2..e0a3ebd1640 100644
--- a/hermes_cli/auth_commands.py
+++ b/hermes_cli/auth_commands.py
@@ -321,7 +321,9 @@ def _add_nous_oauth_credential(args, provider: str) -> PooledCredential:
# Codex-style auto-import: a shared Nous credential at <hermes-root>/shared/nous_auth.json
# (written by any previous login) makes `hermes --profile <name> auth add nous --type oauth`
# a one-tap operation for multi-profile users.
- if auth_mod._read_shared_nous_state():
+ from hermes_cli.anon_auth import is_guest_state
+
+ if (shared := auth_mod._read_shared_nous_state()) and not is_guest_state(shared):
try:
found = f"Found existing Nous OAuth credentials at {auth_mod._nous_shared_store_path()}"
except RuntimeError:
diff --git a/hermes_cli/auth_nous.py b/hermes_cli/auth_nous.py
index 8d363e526fb..52081cab733 100644
--- a/hermes_cli/auth_nous.py
+++ b/hermes_cli/auth_nous.py
@@ -1111,6 +1111,10 @@ def _resolve_nous_runtime_credentials(
with _provider_state_transaction("nous") as (auth_store, state, state_source_path):
if not state:
raise _nous_err("Hermes is not logged into Nous Portal.", "nous_auth_missing", relogin=True)
+ from hermes_cli.anon_auth import guest_without_free_tier
+ if guest_without_free_tier(state):
+ # Not terminal (no relogin): the identity stays for connectors.
+ raise _nous_err("Hermes is not logged into Nous Portal.", "nous_auth_missing")
run = _NousRuntimeResolve(
auth_store, state, state_source_path, force_refresh=force_refresh,
stale_access_token=stale_access_token, timeout_seconds=timeout_seconds)
@@ -1216,9 +1220,10 @@ def _nous_status_from_state(
def _compute_nous_auth_status() -> dict[str, Any]:
"""Uncached implementation of get_nous_auth_status(). See that function."""
+ from hermes_cli.anon_auth import guest_without_free_tier
from hermes_cli.auth import get_provider_auth_state, resolve_nous_runtime_credentials
state = get_provider_auth_state("nous")
- if not state:
+ if not state or guest_without_free_tier(state):
return _snapshot_nous_pool_status()
base_status = _nous_status_from_state(
state, logged_in=bool(state.get("access_token")), source="auth_store")
@@ -1271,12 +1276,13 @@ def get_nous_auth_status_local() -> dict[str, Any]:
``logged_in`` = usable invoke JWT, or a refresh token not terminally quarantined — not proof
the server still accepts it.
"""
+ from hermes_cli.anon_auth import guest_without_free_tier
from hermes_cli.auth import get_provider_auth_state
try:
state = get_provider_auth_state("nous")
except Exception:
state = None
- if not state:
+ if not state or guest_without_free_tier(state):
return _snapshot_nous_pool_status()
jwt_reason = _state_invoke_jwt_status(state, state.get("access_token"))
last_err = _terminal_quarantine_marker(state)
diff --git a/hermes_cli/model_switch_providers.py b/hermes_cli/model_switch_providers.py
index 7a7ad6d665e..615dadbd928 100644
--- a/hermes_cli/model_switch_providers.py
+++ b/hermes_cli/model_switch_providers.py
@@ -498,8 +498,10 @@ def _free_tier_nous_row(row: dict) -> dict | None:
from hermes_cli import anon_auth
if not anon_auth.has_guest():
return row
- if not anon_auth.guest_enabled():
+ if not anon_auth.guest_allowed():
return None
+ if not anon_auth.guest_enabled():
+ return row # a guest kept for connectors only: the row is whatever real Nous login exists
out = dict(row)
out["name"] = anon_auth.FREE_TIER_LABEL
out["models"] = [anon_auth.GUEST_MODEL]
diff --git a/hermes_cli/nous_account.py b/hermes_cli/nous_account.py
index 0e38c06d77c..eb26b0a237a 100644
--- a/hermes_cli/nous_account.py
+++ b/hermes_cli/nous_account.py
@@ -310,10 +310,11 @@ def get_nous_portal_account_info(*, force_fresh: bool = False, min_jwt_ttl_secon
except Exception as exc:
return _error_info(error=exc, logged_in=False)
- # A guest that has only used connectors holds just a connectors-only token (same claims).
- from hermes_cli.anon_auth import held_connectors_token
+ # A guest that has only used connectors holds just a connectors-only token (same claims). With
+ # the free tier off a guest is not an account login: the pool and logged-out answers apply.
+ from hermes_cli.anon_auth import guest_without_free_tier, held_connectors_token
- access_token = held_connectors_token(state) or ""
+ access_token = "" if guest_without_free_tier(state) else (held_connectors_token(state) or "")
portal_base_url = _portal_base_url(state)
if not _nonblank(access_token):
return (
diff --git a/hermes_cli/nous_subscription.py b/hermes_cli/nous_subscription.py
index bb03b09840b..294daff7eca 100644
--- a/hermes_cli/nous_subscription.py
+++ b/hermes_cli/nous_subscription.py
@@ -701,7 +701,10 @@ def _run_nous_portal_login_only(*, capability: str) -> bool:
prior_active_provider = auth._load_auth_store().get("active_provider")
auth_state = None
# Interrupting the import question defaults to importing.
- if auth._read_shared_nous_state() and _confirm(" Found existing Nous OAuth credentials. Import them? [Y/n]: ") is not False:
+ from hermes_cli.anon_auth import is_guest_state
+
+ shared = auth._read_shared_nous_state()
+ if shared and not is_guest_state(shared) and _confirm(" Found existing Nous OAuth credentials. Import them? [Y/n]: ") is not False:
auth_state = auth._try_import_shared_nous_state(timeout_seconds=15.0)
if auth_state is None:
auth_state = auth._nous_device_code_login()
diff --git a/tests/tools/test_connectors_guest_on_first_use.py b/tests/tools/test_connectors_guest_on_first_use.py
index 3e1fe44b731..ce24df17159 100644
--- a/tests/tools/test_connectors_guest_on_first_use.py
+++ b/tests/tools/test_connectors_guest_on_first_use.py
@@ -50,7 +50,18 @@ def test_first_hosted_action_creates_one_connectors_only_guest(nas, monkeypatch)
assert nas.creates() == 1
assert [r["body"].get("purpose") for r in nas.token_requests] == ["connectors"]
assert bearers and all(anon_auth.is_connectors_only(b) for b in bearers)
- assert anon_auth.has_guest() and not anon_auth.has_free_tier_account()
+
+ # The free model and its surfaces stay off; the identity survives for connectors.
+ from hermes_cli.auth_constants import AuthError
+ from hermes_cli.auth_nous import get_nous_auth_status_local, resolve_nous_runtime_credentials
+
+ with pytest.raises(AuthError) as refused:
+ resolve_nous_runtime_credentials()
+ assert refused.value.code == "nous_auth_missing" and not refused.value.relogin_required
+ assert not get_nous_auth_status_local().get("logged_in")
+ assert not anon_auth.guest_notice_pending() and not anon_auth.has_free_tier_account()
+ assert anon_auth.has_guest()
+ assert [r["body"].get("purpose") for r in nas.token_requests] == ["connectors"]
def test_tool_search_without_an_identity_sends_nothing(nas, monkeypatch):