Skip to content

The agent that grows with you

fix: code-health findings on the welcome-trial change

alt-glitch0f98cc349f32
diff --git a/hermes_cli/free_tier_bootstrap.py b/hermes_cli/free_tier_bootstrap.py
index bdaaa232c10..c82e0744594 100644
--- a/hermes_cli/free_tier_bootstrap.py
+++ b/hermes_cli/free_tier_bootstrap.py
@@ -199,8 +199,8 @@ def run_bootstrap(*, announce: bool = True) -> SetupRecord:
try:
from hermes_cli.welcome_trial import grandfather_existing_guest
grandfather_existing_guest()
- except Exception as exc: # the record still says who carries inference without it
- logger.info("free tier: could not check for an existing free-model guest: %s", exc)
+ except Exception: # the record still says who carries inference without it
+ logger.warning("free tier: could not check for an existing free-model guest", exc_info=True)
record = _build_record(other=_inventory_other_providers())
with _lock:
_record = record
@@ -234,6 +234,8 @@ def _broadcast(record: SetupRecord) -> None:
def start_background_bootstrap() -> threading.Thread:
"""``hermes serve`` entry: run on a daemon thread so the inventory never delays the socket."""
- thread = threading.Thread(target=run_bootstrap, daemon=True, name="free-tier-bootstrap")
+ from agent.memory_provider import spawn_context_thread
+
+ thread = spawn_context_thread(run_bootstrap, name="free-tier-bootstrap")
thread.start()
return thread
diff --git a/hermes_cli/process_identity.py b/hermes_cli/process_identity.py
index 07897148e4d..ddae5d5ea16 100644
--- a/hermes_cli/process_identity.py
+++ b/hermes_cli/process_identity.py
@@ -262,7 +262,7 @@ def is_desktop_owned_backend(argv: Optional[Sequence[str]] = None) -> bool:
def is_local_desktop_backend() -> bool:
"""The backend Desktop spawned on this machine: the local pool spawn's credential, never the
SSH spawn (its token arrives as a file on argv, and that host is another computer)."""
- return os.environ.get("HERMES_DESKTOP") == "1" and bool(os.environ.get("HERMES_DASHBOARD_SESSION_TOKEN"))
+ return os.environ.get("HERMES_DESKTOP") == "1" and os.environ.get("HERMES_DASHBOARD_SESSION_TOKEN", "") != ""
def _desktop_spawner_identity() -> tuple[Optional[int], Optional[float]]:
diff --git a/hermes_cli/welcome_trial.py b/hermes_cli/welcome_trial.py
index 06dc1753bc1..12e9ce825f4 100644
--- a/hermes_cli/welcome_trial.py
+++ b/hermes_cli/welcome_trial.py
@@ -34,10 +34,11 @@ def provider_configured() -> bool:
"""Something besides the welcome trial carries inference: a key, a config pin, a sign-in, a host
credential. The resolver itself answers, with the free-tier rung hidden."""
from hermes_cli.auth import resolve_provider
+ from hermes_cli.auth_constants import AuthError
try:
provider = resolve_provider("auto", skip_free_tier=True)
- except Exception: # no_provider_configured, or an unreadable store: nothing usable here
+ except AuthError: # no_provider_configured
return False
return provider != "nous" or not anon_auth.has_guest()
diff --git a/tui_gateway/methods_free_tier.py b/tui_gateway/methods_free_tier.py
index 51db9b65dbb..2047ce003a8 100644
--- a/tui_gateway/methods_free_tier.py
+++ b/tui_gateway/methods_free_tier.py
@@ -69,10 +69,11 @@ def _(rid, params: dict) -> dict:
enabled}``, plus ``{error, error_code, retryable, retry_after}`` when the portal refused."""
try:
from hermes_cli import anon_auth, free_tier_bootstrap, welcome_trial
+ from hermes_cli.auth_constants import AuthError
if _trial_claimable():
try:
welcome_trial.claim_desktop_free_tier(force=True)
- except Exception as exc: # memoised by the mint primitive before it re-raised
+ except AuthError as exc: # memoised by the mint primitive before it re-raised
logger.info("welcome trial claim failed: %s", exc)
if not params.get("profile"):
# The launch profile: ``setup.status`` and the ``setup.ready`` listeners move with it.