Skip to content

The agent that grows with you

chore(auth): drop the unused tool:invoke OAuth scope from the step-up request (#118036)

Siddharth Balyan080907e3b7ad
diff --git a/hermes_cli/auth_nous.py b/hermes_cli/auth_nous.py
index b7c185e1ec7..48e07be2a8c 100644
--- a/hermes_cli/auth_nous.py
+++ b/hermes_cli/auth_nous.py
@@ -1419,11 +1419,11 @@ def step_up_nous_billing_scope(
prior = get_provider_auth_state("nous") or {}
pconfig = PROVIDER_REGISTRY["nous"]
# Step-up scope: existing scopes (if any) + billing:manage, deduped, order-stable. Falls back
- # to the standard inference+tool+billing set.
+ # to the standard inference+billing set.
_raw_scope = prior.get("scope")
prior_scope = _raw_scope.split() if isinstance(_raw_scope, str) else []
requested = list(dict.fromkeys([
- *(prior_scope or [NOUS_INFERENCE_INVOKE_SCOPE, "tool:invoke"]), NOUS_BILLING_MANAGE_SCOPE]))
+ *(prior_scope or [NOUS_INFERENCE_INVOKE_SCOPE]), NOUS_BILLING_MANAGE_SCOPE]))
auth_state = _nous_device_code_login(
portal_base_url=prior.get("portal_base_url") or None,
inference_base_url=prior.get("inference_base_url") or None,
diff --git a/tests/gateway/test_free_tier_startup_notice.py b/tests/gateway/test_free_tier_startup_notice.py
index 0d703d9fefa..04eefcda121 100644
--- a/tests/gateway/test_free_tier_startup_notice.py
+++ b/tests/gateway/test_free_tier_startup_notice.py
@@ -21,7 +21,7 @@ def _jwt(**claims) -> str:
def seg(obj):
return base64.urlsafe_b64encode(json.dumps(obj).encode()).rstrip(b"=").decode()
payload = {"sub": "nas_user:1", "client_id": "nas-anonymous", "account_tier": "anonymous",
- "scope": "inference:invoke tool:invoke", "exp": int(time.time()) + 900, **claims}
+ "scope": "inference:invoke", "exp": int(time.time()) + 900, **claims}
return f"{seg({'alg': 'RS256'})}.{seg(payload)}.sig"
diff --git a/tests/gateway/test_status_free_tier_line.py b/tests/gateway/test_status_free_tier_line.py
index f979e2613e6..eb33f4d107b 100644
--- a/tests/gateway/test_status_free_tier_line.py
+++ b/tests/gateway/test_status_free_tier_line.py
@@ -36,7 +36,7 @@ def _jwt(**claims) -> str:
"sub": "nas_user:status",
"client_id": "nas-anonymous",
"account_tier": "anonymous",
- "scope": "inference:invoke tool:invoke",
+ "scope": "inference:invoke",
"exp": int(time.time()) + 900,
**claims,
}
diff --git a/tests/hermes_cli/anon_portal.py b/tests/hermes_cli/anon_portal.py
index 573363b1473..52bf84c2066 100644
--- a/tests/hermes_cli/anon_portal.py
+++ b/tests/hermes_cli/anon_portal.py
@@ -22,7 +22,7 @@ def make_jwt(**claims) -> str:
def seg(obj):
return base64.urlsafe_b64encode(json.dumps(obj).encode()).rstrip(b"=").decode()
payload = {"sub": "nas_user:1", "client_id": "nas-anonymous", "account_tier": "anonymous",
- "scope": "inference:invoke tool:invoke", "exp": int(time.time()) + 900, **claims}
+ "scope": "inference:invoke", "exp": int(time.time()) + 900, **claims}
return f"{seg({'alg': 'RS256'})}.{seg(payload)}.sig"
diff --git a/tests/hermes_cli/test_anon_first_notice.py b/tests/hermes_cli/test_anon_first_notice.py
index 6d0c956cd5f..d5b091b02f3 100644
--- a/tests/hermes_cli/test_anon_first_notice.py
+++ b/tests/hermes_cli/test_anon_first_notice.py
@@ -15,7 +15,7 @@ def _jwt(**claims) -> str:
def seg(obj):
return base64.urlsafe_b64encode(json.dumps(obj).encode()).rstrip(b"=").decode()
payload = {"sub": "nas_user:1", "client_id": "nas-anonymous", "account_tier": "anonymous",
- "scope": "inference:invoke tool:invoke", "exp": int(time.time()) + 900, **claims}
+ "scope": "inference:invoke", "exp": int(time.time()) + 900, **claims}
return f"{seg({'alg': 'RS256'})}.{seg(payload)}.sig"
diff --git a/tests/hermes_cli/test_anon_surfaces.py b/tests/hermes_cli/test_anon_surfaces.py
index d29919881b1..9272b7662f4 100644
--- a/tests/hermes_cli/test_anon_surfaces.py
+++ b/tests/hermes_cli/test_anon_surfaces.py
@@ -42,7 +42,7 @@ def _jwt(**claims) -> str:
def seg(obj):
return base64.urlsafe_b64encode(json.dumps(obj).encode()).rstrip(b"=").decode()
payload = {"sub": "nas_user:abc", "client_id": "nas-anonymous", "account_tier": "anonymous",
- "scope": "inference:invoke tool:invoke", "exp": int(time.time()) + 10 ** 8, **claims}
+ "scope": "inference:invoke", "exp": int(time.time()) + 10 ** 8, **claims}
return f"{seg({'alg': 'RS256'})}.{seg(payload)}.sig"
diff --git a/tests/hermes_cli/test_anon_upgrade.py b/tests/hermes_cli/test_anon_upgrade.py
index 4e5657daa11..fde6147e884 100644
--- a/tests/hermes_cli/test_anon_upgrade.py
+++ b/tests/hermes_cli/test_anon_upgrade.py
@@ -30,7 +30,7 @@ def _jwt(**claims) -> str:
def seg(obj):
return base64.urlsafe_b64encode(json.dumps(obj).encode()).rstrip(b"=").decode()
payload = {"sub": "nas_user:1", "client_id": "nas-anonymous", "account_tier": "anonymous",
- "scope": "inference:invoke tool:invoke", "exp": int(time.time()) + 900, **claims}
+ "scope": "inference:invoke", "exp": int(time.time()) + 900, **claims}
return f"{seg({'alg': 'RS256'})}.{seg(payload)}.sig"
@@ -89,7 +89,7 @@ class FakePortal:
return httpx.Response(200, json={
"access_token": _jwt(sub="nas_user:9", client_id="hermes-cli", account_tier="free"),
"refresh_token": REFRESH_TOKEN, "token_type": "Bearer", "expires_in": 900,
- "scope": "inference:invoke tool:invoke", "inference_base_url": INFERENCE})
+ "scope": "inference:invoke", "inference_base_url": INFERENCE})
return httpx.Response(500, json={"error": f"unexpected {path}"})
diff --git a/tests/hermes_cli/test_billing_scope_stepup.py b/tests/hermes_cli/test_billing_scope_stepup.py
index c1520776f0c..2cc7facb7c8 100644
--- a/tests/hermes_cli/test_billing_scope_stepup.py
+++ b/tests/hermes_cli/test_billing_scope_stepup.py
@@ -73,7 +73,7 @@ def test_step_up_requests_billing_scope_and_reuses_prior_urls(monkeypatch, _stub
auth,
"get_provider_auth_state",
lambda p: {
- "scope": "inference:invoke tool:invoke",
+ "scope": "inference:invoke",
"portal_base_url": "https://preview.example.com",
"inference_base_url": "https://inf.example.com",
"client_id": "hermes-cli",
@@ -84,16 +84,15 @@ def test_step_up_requests_billing_scope_and_reuses_prior_urls(monkeypatch, _stub
def _fake_login(**kw):
captured.update(kw)
# Simulate the admin ticking the box → token comes back WITH the scope.
- return {"scope": "inference:invoke tool:invoke billing:manage", "access_token": "t"}
+ return {"scope": "inference:invoke billing:manage", "access_token": "t"}
monkeypatch.setattr(auth, "_nous_device_code_login", _fake_login)
monkeypatch.setattr(auth_nous, "_nous_device_code_login", _fake_login)
granted = step_up_nous_billing_scope()
assert granted is True
- # Requested scope must include billing:manage, preserving prior scopes.
- assert NOUS_BILLING_MANAGE_SCOPE in captured["scope"].split()
- assert "inference:invoke" in captured["scope"].split()
+ # Requests the granted inference scope plus billing access.
+ assert captured["scope"] == "inference:invoke billing:manage"
# Reuses the prior credential's deployment URLs (so a preview stays a preview).
assert captured["portal_base_url"] == "https://preview.example.com"
assert captured["client_id"] == "hermes-cli"
diff --git a/tests/tui_gateway/test_free_tier_rpc.py b/tests/tui_gateway/test_free_tier_rpc.py
index b158a5dc69c..3727f9ac9b3 100644
--- a/tests/tui_gateway/test_free_tier_rpc.py
+++ b/tests/tui_gateway/test_free_tier_rpc.py
@@ -18,7 +18,7 @@ def _jwt(**claims) -> str:
def seg(obj):
return base64.urlsafe_b64encode(json.dumps(obj).encode()).rstrip(b"=").decode()
payload = {"sub": "nas_user:1", "client_id": "nas-anonymous", "account_tier": "anonymous",
- "scope": "inference:invoke tool:invoke", "exp": int(time.time()) + 900, **claims}
+ "scope": "inference:invoke", "exp": int(time.time()) + 900, **claims}
return f"{seg({'alg': 'RS256'})}.{seg(payload)}.sig"