Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(model-hub): classify CLIProxyAPI's Claude timeout_error as a server error (#2467)

Call White21951593b193
diff --git a/core/handlers/model_hub/classification.py b/core/handlers/model_hub/classification.py
index f08726f28..b28d1020d 100644
--- a/core/handlers/model_hub/classification.py
+++ b/core/handlers/model_hub/classification.py
@@ -135,6 +135,9 @@ _MACHINE_ERROR_TAXONOMY: Final[Mapping[str, _MachineErrorRule]] = {
"server", True, 70, "fallback", "server_error", None, 30, None
),
"upstream_error": _MachineErrorRule("server", True, 70, "fallback", "server_error", None, 30, None),
+ # CLIProxyAPI's Claude-shaped error type for an upstream 408 or 504; its OpenAI
+ # shape is type server_error with code request_timeout.
+ "timeout_error": _MachineErrorRule("server", True, 70, "fallback", "server_error", None, 30, None),
}
MACHINE_ERROR_CODES: Final = frozenset(_MACHINE_ERROR_TAXONOMY)
UPSTREAM_MACHINE_ERROR_CODES: Final = frozenset(
diff --git a/docs/plans/model-hub-contracts/turn-provenance.schema.json b/docs/plans/model-hub-contracts/turn-provenance.schema.json
index 6e72e2760..5914c8afd 100644
--- a/docs/plans/model-hub-contracts/turn-provenance.schema.json
+++ b/docs/plans/model-hub-contracts/turn-provenance.schema.json
@@ -213,6 +213,7 @@
"api_error",
"service_unavailable_error",
"upstream_error",
+ "timeout_error",
null
],
"description": "Optional observed machine code from classification.UPSTREAM_MACHINE_ERROR_CODES. If model_not_found was observed and classification returned upstream_request_invalid, retain that specific code over a co-occurring generic invalid_request_error type; otherwise use existing specificity order. This diagnostic selection never reranks or changes classification. Never derive a code from invalid_parameter; unknown codes, bodies, headers and credentials are not retained. Absent evidence is null; historical records may omit the field."
diff --git a/tests/test_model_hub_runtime.py b/tests/test_model_hub_runtime.py
index 61adeb7ed..23de5ae71 100644
--- a/tests/test_model_hub_runtime.py
+++ b/tests/test_model_hub_runtime.py
@@ -38,6 +38,7 @@ from core.handlers.model_hub.adapter import (
)
from core.handlers.model_hub.classification import (
classify_outcome,
+ source_settlement_rule,
terminal_outcome_category,
)
from core.handlers.model_hub.errors import ModelDiscoveryError
@@ -7432,6 +7433,26 @@ def test_engine_buffered_2xx_error_envelope_carries_upstream_detail() -> None:
assert outcome.upstream_detail == "model retired"
+def test_engine_claude_timeout_error_falls_back_with_a_server_cooldown() -> None:
+ # CLIProxyAPI v8 answers an upstream 408 on /v1/messages with this body.
+ body = json.dumps(
+ {"type": "error", "error": {"type": "timeout_error", "message": "upstream request timed out"}}
+ ).encode()
+
+ observation = observe_buffered_protocol_response("anthropic", io.BytesIO(body))
+ outcome = client_module._reduce_protocol_observation(
+ observation,
+ source=_detail_source(),
+ model_id="model-a",
+ http_status=408,
+ stream_started=False,
+ )
+ decision = classify_outcome(outcome)
+
+ assert (decision.action, decision.reason, decision.cooldown_seconds) == ("fallback", "server_error", 30)
+ assert source_settlement_rule(decision.reason).status == "cooldown"
+
+
_ANTHROPIC_OUTPUT_STARTED = (
b'event: message_start\ndata: {"type":"message_start","message":{"id":"msg_1","type":"message",'
b'"role":"assistant","content":[],"model":"model-a","usage":{"input_tokens":1,"output_tokens":0}}}\n\n'
diff --git a/tests/test_model_hub_structure_guards.py b/tests/test_model_hub_structure_guards.py
index 1bfc93dac..cb0e6826d 100644
--- a/tests/test_model_hub_structure_guards.py
+++ b/tests/test_model_hub_structure_guards.py
@@ -300,6 +300,7 @@ MACHINE_ERROR_FAMILY_FIXTURES = {
"api_error",
"service_unavailable_error",
"upstream_error",
+ "timeout_error",
),
"transient": (
"rate_limit_error",