Suppress "Credit access paused" notice on free models (#43669)

* don't show credits message on free model

* PR comments
This commit is contained in:
rob-maron
2026-06-10 23:55:06 +05:30
committed by GitHub
parent 6de3963e37
commit 6110aed9be
4 changed files with 238 additions and 18 deletions
+9 -2
View File
@@ -2831,11 +2831,18 @@ class AIAgent:
if state is None:
return
try:
from agent.credits_tracker import evaluate_credits_notices
from agent.credits_tracker import evaluate_credits_notices, is_free_tier_model
latch = getattr(self, "_credits_latch", None)
if latch is None:
latch = self._credits_latch = {"active": set(), "seen_below_90": False, "usage_band": None}
to_show, to_clear = evaluate_credits_notices(state, latch)
# Free-model gate: a depleted account on a free model can still
# inference, so the depleted error banner is suppressed. Local-data
# only (":free" suffix + pricing-cache peek) — never a network call.
model_is_free = is_free_tier_model(
getattr(self, "model", "") or "",
getattr(self, "base_url", "") or "",
)
to_show, to_clear = evaluate_credits_notices(state, latch, model_is_free=model_is_free)
for key in to_clear: # clears FIRST …
self._emit_notice_clear(key)
for notice in to_show: # … then shows (depleted lands last in a latest-wins slot)