no warning when api-key in arrearage There is no response for chat when api-key in…
- User
no warning when api-key in arrearage There is no response for chat when api-key in arrearage, please give me a warning
Evaluation contract
Treat HTTP 402, normalized billing/quota tokens such as
insufficient_quota,quota_exceeded,quota_exhausted,billing_hard_limit_reached, andpayment_required, and unambiguous billing text such as “exceeded your current quota”, “insufficient balance”, or “payment required” as account-arrearage failures. Surface a non-empty billing-specific message that does not expose the raw provider dump and takes precedence over a configured generic error message. A plain HTTP 429rate_limit_exceeded, timeouts, connection failures, HTTP 5xx responses, successful responses, and ordinary text that merely mentions a quota are not arrearage. Persist only the existing model-error placeholder in session history.Interface
Type: Function Name: is_arrearage_response Path: nanobot/providers/base.py Input: cls, response: LLMResponse Output: bool Description: Detects API-key arrearage, quota, or billing errors that won't clear on retry. Returns True for HTTP 402 status, billing semantic tokens (e.g., 'insufficient_quota'), or matching text markers in the response content.
- Assistant
Let me look at the placeholder persistence and where the error branch persists history.
- Assistant
Now I'll add the
is_arrearage_responseclassmethod to the provider base: - Assistant
Now add the classmethod itself, after
_is_retryable_429_response: - Assistant
Also short-circuit retries for arrearage in the retry policy (a legacy-provider quota dump mentioning "429" would otherwise be retried as transient):
- Assistant
Now let's look at the existing retry tests to add coverage in the same style:
- Assistant
Now the runner test for the billing warning:
- Assistant
1581 tests pass. The ruff I001 warnings flag pre-existing imports in that test file too — let me check whether tests are part of the lint scope:
- Assistant
The pre-existing file already fails I001 (project CI lints
nanobot/only per CLAUDE.md), but I'll auto-fix the whole file so my additions don't add noise: - Assistant
That failure is pre-existing on a clean tree (fails without my changes too) and unrelated — everything else passes (3702 passed).
Summary
Problem: When the API key is in arrearage (billing/quota exhausted), the chat produced no useful response — the user got silence or a generic error with no hint that their account balance was the cause.
Changes:
-
nanobot/providers/base.py— addedLLMProvider.is_arrearage_response(cls, response)classmethod that detects billing failures which won't clear on retry:
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.