ISSUE DESCRIPTION no warning when api-key in arrearage There is no response for chat…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
Assistant
Now let's implement the
is_arrearage_responseclassmethod in base.py, near_is_retryable_429_response.Assistant
Good. Now let's wire this into runner.py to surface a billing-specific message.
Assistant
Now update the finish_reason == "error" branch to use this message when arrearage.
Assistant
Good, that confirms error_status_code gets populated from actual HTTP status (e.g., 402). Now let's write a quick reproduction/test script to verify the new function and runner wiring works correctly.
Assistant
All cases pass. Now let's run existing test suites for providers and runner to make sure nothing broke.
Assistant
All passing. Let's run the full test suite to be safe.
Assistant
Confirmed this failure is pre-existing and unrelated to our change. Now let's double check the final diff.
Assistant
The diff looks clean and focused. Let's also verify placeholder persistence behavior is unaffected — check
_append_model_error_placeholderstill called unconditionally regardless of arrearage (it is, unchanged).Assistant
This satisfies "Persist only the existing model-error placeholder in session history" — the placeholder mechanism is unchanged; only the surfaced
final_content/errordiffers, not what's persisted tomessages.Now let's write a quick end-to-end reproduction test to simulate the whole runner flow with an arrearage error, to fully confirm behavior.
Assistant
Good, this confirms rate-limit-exceeded doesn't trigger arrearage (final_content stays raw as before, test still passes since we verified). Let's write a quick script mimicking arrearage flow.
Assistant
Excellent, end-to-end verified. Let's also confirm that a configured
error_message(generic) doesn't override the arrearage message, per contract "takes precedence over a configured generic error message."Assistant
All the required behaviors are confirmed. Let's finalize by re-running the full relevant test suites once more.
Assistant
All 1557 tests pass. Now let's go through the checklist.
Assistant
This confirms the "before" behavior exposed the raw provider dump (matching the issue's complaint about no clear warning), and the "after" behavior produces a clear billing-specific warning. Everything is verified.
Assistant
The changes are minimal, focused, and fully address the issue. Let me do a final review of the checklist:
Checklist review:
-
Reproduced the reported error: The issue states "no warning when api-key in arrearage." I reproduced this by simulating a provider response with
insufficient_quota/billing error and confirmed viagit stashcomparison that, before the fix,final_contentwas the raw provider JSON dump ({"error": {"type": "insufficient_quota", ...}}) — i.e., no clear warning, just a confusing raw dump surfacing (or worse, silence in other paths). ✅
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.