Fix: Pro users with OAuth tokens incorrectly classified as free

#21
by Marco333 - opened
Files changed (1) hide show
  1. agent/core/hf_access.py +5 -3
agent/core/hf_access.py CHANGED
@@ -55,6 +55,11 @@ def _extract_username(whoami: dict[str, Any]) -> str | None:
55
 
56
 
57
  def _normalize_personal_plan(whoami: dict[str, Any]) -> str:
 
 
 
 
 
58
  plan_str = ""
59
  for key in ("plan", "type", "accountType"):
60
  value = whoami.get(key)
@@ -62,9 +67,6 @@ def _normalize_personal_plan(whoami: dict[str, Any]) -> str:
62
  plan_str = value.lower()
63
  break
64
 
65
- if not plan_str and (whoami.get("isPro") is True or whoami.get("is_pro") is True):
66
- return "pro"
67
-
68
  if any(tag in plan_str for tag in ("pro", "enterprise", "team")):
69
  return "pro"
70
  return "free"
 
55
 
56
 
57
  def _normalize_personal_plan(whoami: dict[str, Any]) -> str:
58
+ # Check isPro / is_pro first — this is the most reliable signal
59
+ # and is always present in OAuth whoami responses.
60
+ if whoami.get("isPro") is True or whoami.get("is_pro") is True:
61
+ return "pro"
62
+
63
  plan_str = ""
64
  for key in ("plan", "type", "accountType"):
65
  value = whoami.get(key)
 
67
  plan_str = value.lower()
68
  break
69
 
 
 
 
70
  if any(tag in plan_str for tag in ("pro", "enterprise", "team")):
71
  return "pro"
72
  return "free"