The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(credits): fold review findings for stealth free-tier fix
kshitijk4poor8a949659c3e5
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.pyindex 7322a14b9a4..31e99c0e5b2 100644--- a/agent/auxiliary_client.py+++ b/agent/auxiliary_client.py@@ -2830,8 +2830,11 @@ _paid_lane_warned: set = set()def _is_free_model(model: Optional[str]) -> bool:- """True when ``model`` is an OpenRouter free SKU (``:free`` suffix)."""- return bool(model) and str(model).strip().endswith(":free")+ """True when ``model`` is a free SKU (``:free`` suffix or ``stealth/`` prefix)."""+ if not model:+ return False+ normalized = str(model).strip()+ return normalized.endswith(":free") or normalized.startswith("stealth/")def _aux_openrouter_settings() -> Tuple[bool, str]:diff --git a/agent/credits_tracker.py b/agent/credits_tracker.pyindex 59887730441..39c74ea58b9 100644--- a/agent/credits_tracker.py+++ b/agent/credits_tracker.py@@ -244,13 +244,9 @@ def is_free_tier_model(model: str, base_url: str = "") -> bool:return Falseif model.endswith(":free"):return True- # Stealth-preview SKUs (e.g. stealth/ox-alpha) are free-tier but carry no- # ``:free`` suffix. Spend is forced to zero server-side, so a ``paid_access:- # false`` header on these models is a false positive for the depleted banner.- # The ``stealth/`` prefix is the Nous naming convention for these SKUs and- # is checked here as a zero-network signal, same design as the ``:free``- # suffix above. Fail-open to False (the banner still shows) if the prefix- # ever changes — recoverable noise, never a masked depletion on a paid model.+ # Stealth-preview SKUs are free-tier but carry no ``:free`` suffix (see+ # docstring point 2). Naming-convention trust: if a PAID model ever shipped+ # under ``stealth/`` this would wrongly suppress the banner on it.if model.startswith("stealth/"):return Trueif not base_url:diff --git a/run_agent.py b/run_agent.pyindex 62377381419..6704ad7cbdd 100644--- a/run_agent.py+++ b/run_agent.py@@ -4251,7 +4251,8 @@ class AIAgent:latch = self._credits_latch = new_credits_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.+ # only (":free" suffix, "stealth/" prefix + pricing-cache peek) —+ # never a network call.model_is_free = is_free_tier_model(getattr(self, "model", "") or "",getattr(self, "base_url", "") or "",diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.pyindex ad4966acaa3..238c9e50384 100644--- a/tests/agent/test_auxiliary_client.py+++ b/tests/agent/test_auxiliary_client.py@@ -1071,7 +1071,10 @@ class TestOpenRouterPaidLaneGuard:def test_is_free_model(self):from agent.auxiliary_client import _is_free_modelassert _is_free_model("nvidia/nemotron-3-ultra-550b-a55b:free")+ # Stealth-preview SKUs are free-tier without a :free suffix (issue #91843).+ assert _is_free_model("stealth/ox-alpha")assert not _is_free_model("google/gemini-3.6-flash")+ assert not _is_free_model("my-stealth/model")assert not _is_free_model("")assert not _is_free_model(None)