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
Now let me find where model errors are surfaced to the user (the generic error message path) in the runner:
- Assistant
Let me check how providers construct error responses and how the loop/session persist errors:
- Assistant
Now let me check existing tests for these paths:
- Assistant
Now the runner — add the billing-specific message and use it in the error path:
- Assistant
Now verify how session history is persisted after a turn to confirm only
result.messages(with placeholder) is saved: - Assistant
Session persistence goes through
result.messages, which only contains the placeholder on error — the billing warning stays outbound-only. Now let me add tests. First check existing runner test conventions: - Assistant
Now add tests. First a provider-level test file:
- Assistant
Now add a runner-level test to
test_runner_errors.py: - Assistant
The ruff I001 warnings also flag pre-existing lines — let me check if this file already failed ruff before my change:
- Assistant
All tests pass. Here's a summary of the fix:
Problem
When an API key is in arrearage (out of credit / quota exhausted), the provider error either surfaced as a raw provider dump or got swallowed, leaving the user with no useful response and no idea what went wrong.
Changes
nanobot/providers/base.py- Added
LLMProvider.is_arrearage_response(cls, response)classmethod that detects billing failures which won't clear on retry:
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.