Skip to content

The agent that grows with you

fix(auth): Nous unusable-JWT-without-refresh-token is a terminal pool failure

teknium15dbeaf2366bf
diff --git a/hermes_cli/auth_nous.py b/hermes_cli/auth_nous.py
index a3b510f2e3b..b7c185e1ec7 100644
--- a/hermes_cli/auth_nous.py
+++ b/hermes_cli/auth_nous.py
@@ -36,12 +36,17 @@ _UNUSABLE_JWT_RELOGIN = "Re-authenticate with: hermes auth add nous"
def _unusable_invoke_jwt_error(reason: str, *, no_refresh_token: bool = False) -> AuthError:
- """Shared ``relogin=True`` error for an access token that is not a usable inference JWT."""
+ """Shared ``relogin=True`` error for an access token that is not a usable inference JWT.
+
+ With no refresh token the failure is a state-shape one (nothing to redeem), so it carries the
+ terminal ``nous_auth_missing_refresh_token`` code the pool recognises instead of the JWT
+ ``reason``, which would bench the row as a transient outage (#113718).
+ """
detail = " and no refresh token is available" if no_refresh_token else ""
return _nous_err(
f"Nous Portal access token is not a usable inference JWT ({reason}){detail}. "
f"{_UNUSABLE_JWT_RELOGIN}",
- reason, relogin=True)
+ "nous_auth_missing_refresh_token" if no_refresh_token else reason, relogin=True)
def _token_fingerprint(token: Any) -> Optional[str]:
diff --git a/tests/hermes_cli/test_auth_nous_provider.py b/tests/hermes_cli/test_auth_nous_provider.py
index 8add56de1d4..7f5f1177278 100644
--- a/tests/hermes_cli/test_auth_nous_provider.py
+++ b/tests/hermes_cli/test_auth_nous_provider.py
@@ -284,7 +284,9 @@ def test_resolve_nous_runtime_credentials_reauths_when_invoke_scope_missing(
with pytest.raises(AuthError) as exc:
auth_mod.resolve_nous_runtime_credentials()
- assert exc.value.code == "missing_inference_invoke_scope"
+ # No refresh token to redeem: the terminal state-shape code, with the JWT reason in the message.
+ assert exc.value.code == "nous_auth_missing_refresh_token"
+ assert "missing_inference_invoke_scope" in str(exc.value)
assert exc.value.relogin_required is True
payload = json.loads((hermes_home / "auth.json").read_text())
assert payload["providers"]["nous"]["agent_key"] is None