fix(providers): surface clear arrearage warning on quota/billing errors (#3006)

This commit is contained in:
04cb
2026-05-29 15:31:17 +08:00
committed by Xubin Ren
parent 672fabe5be
commit 9d3fe7c34b
4 changed files with 70 additions and 1 deletions
@@ -1,6 +1,9 @@
from types import SimpleNamespace
import pytest
from nanobot.providers.anthropic_provider import AnthropicProvider
from nanobot.providers.base import LLMProvider, LLMResponse
from nanobot.providers.openai_compat_provider import OpenAICompatProvider
@@ -79,3 +82,14 @@ def test_anthropic_handle_error_marks_connection_kind() -> None:
assert response.finish_reason == "error"
assert response.error_kind == "connection"
@pytest.mark.parametrize("expected, kwargs", [
(True, {"error_status_code": 402}), # HTTP 402
(True, {"error_type": "insufficient_quota"}), # billing token
(True, {"content": "429 You exceeded your current quota"}), # text marker
(False, {"error_status_code": 429, "error_type": "rate_limit_exceeded"}), # plain rate limit
])
def test_is_arrearage_response(expected: bool, kwargs: dict) -> None:
response = LLMResponse(finish_reason="error", **{"content": "boom", **kwargs})
assert LLMProvider.is_arrearage_response(response) is expected