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
Good, status codes are captured generically. Let's check test_provider_retry.py near arrearage-relevant test to see conventions used for LLMResponse construction, and check
_is_retryable_429_responsetests for style.Assistant
Now let's implement
is_arrearage_responsein base.py, plus a billing message constant, and wire it into runner.py's error handling.Assistant
Now let's add the
is_arrearage_responseclassmethod right after_is_retryable_429_response, plus a billing status code constant.Assistant
Now let's add a "billing message" constant and the
is_arrearage_responseclassmethod after_is_retryable_429_response.Assistant
Good,
responseis the LLMResponse from the provider. Now let's add the billing message constant and modify the error branch.Assistant
Now let's update the error handling block to use the arrearage detection.
Assistant
This looks good.
_append_model_error_placeholder(messages)is unchanged, preserving the existing placeholder in history. Now let's check other places in the codebase where similar error-final-content logic exists (e.g., other entry points, or cli/telegram handlers) that also need this warning surfaced.Assistant
That's unrelated to chat user-facing warning (memory consolidation), so no change needed there. Now let's write a quick reproduction/test script to verify behavior.
Assistant
All scenarios pass. Now let's write a test for the runner integration to make sure the billing message takes precedence over configured error_message and doesn't expose the raw dump, while persisting only the placeholder.
Assistant
Now let's run the existing test suite for providers and runner to ensure nothing is broken.
Assistant
All 1557 tests pass. Let's also run the full test suite quickly to be safe, and clean up the temp script.
Assistant
Confirmed pre-existing failure unrelated to our change. Now clean up the temp test script and review the diff.
Assistant
The diff is clean and focused. Let's run the full test suite once more for providers and agent tests, plus a quick check on
test_llm_response.pyfor LLMResponse dataclass equality.Assistant
All relevant tests pass. Let's review the checklist.
Checklist review
- If an error was reported in the issue description, I have successfully reproduced it.
I traced the code path: when a provider returns
finish_reason="error"(e.g., due to a 402/insufficient_quota billing failure),runner.pypreviously just surfaced the raw provider dump (clean) or a generic configurederror_message, with no billing-specific warning distinguishing an unrecoverable arrearage condition from a transient error. I wrote a reproduction script (/tmp/test_arrearage_runner.py) simulating aninsufficient_quota429/billing response and confirmed the runner returned the raw provider error content (insufficient_quotaJSON dump) rather than any warning — reproducing the "no warning for arrearage" issue.
- If an error was reported in the issue description, I have successfully reproduced it.
I traced the code path: when a provider returns
Assistant
Confirmed: before the fix, the raw provider dump was surfaced directly (no billing-specific warning). This matches the issue's complaint of "no warning" — instead of a clear warning, users just see either a raw JSON dump or nothing meaningful.
Assistant
- I have confirmed that my fix resolves the error. ✅ As shown above, after the fix, the runner surfaces a clear, non-empty, billing-specific warning message instead of the raw provider dump — resolving the "no warning" issue.
- I have thought about edge cases and made sure my fix handles them as well.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.