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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(model-hub): report the engine's unregistered routed model as a local engine_down (#2471)
Call Whitea4e6a6943aec
diff --git a/docs/plans/model-hub-retry-experience.md b/docs/plans/model-hub-retry-experience.mdindex b848d3880..79e63def9 100644--- a/docs/plans/model-hub-retry-experience.md+++ b/docs/plans/model-hub-retry-experience.md@@ -175,7 +175,7 @@ whose settlement generation is stale.| Recoverable rate limit | 60, 120, 240, 300 seconds; cap 300 | Keep existing cooldown classification. || Recoverable quota exhaustion | 300 seconds | Keep existing cooldown; normally beyond the automatic window. || Refreshable credential rejection | Existing same-Source retry once | No independent retry loop; a second rejection follows the existing terminal rule. |-| Bad key, revoked access, balance requiring action, request/schema/context/model errors, local engine failure | No new automatic retry | Keep existing classification/remedy; `engine_down` never blames or cools an upstream Source. |+| Bad key, revoked access, balance requiring action, request/schema/context/model errors, local engine failure | No new automatic retry | Keep existing classification/remedy; `engine_down` never blames or cools an upstream Source. The engine's pre-egress "unknown provider" for its own routed model is a local `engine_down`, not an upstream rejection, and is not retried. |Apply bounded positive jitter to the local base: a sampled delay in`[base, min(cap, base * 1.2)]`. This preserves minimum delays and hard caps;diff --git a/docs/plans/model-hub.md b/docs/plans/model-hub.mdindex b3897a449..d09152e49 100644--- a/docs/plans/model-hub.md+++ b/docs/plans/model-hub.md@@ -638,8 +638,11 @@ the separate engine boundary and remaining compatibility limitations are recordeParameter, protocol, and tool-compatibility failures are terminal without fallthrough.A local Gateway start, listener, or process loss at **any** request phase is terminal`engine_down`: it mutates no Source, does not replay output, and does not walk another-hop. Credential failures follow the authoritative matrix below. The network-failure-matrix owns every upstream transport branch. While `stream_started` is false, shaped+hop. CLIProxyAPI's pre-egress rejection of a routed model it has not registered (yet), a+400 `unknown provider for model <prefix>/<model>` naming the request's own routed model,+is this local `engine_down` too: the engine has not registered the routed model, which is+not an upstream rejection. Credential failures follow the authoritative matrix below. The+network-failure matrix owns every upstream transport branch. While `stream_started` is false, shapedquota/429/authentication/5xx results retain their existing classifier while anunclassified connection failure creates only live short backoff. The fact flips only atthe first user-visible model-output byte, never at HTTP status, headers, or anotherdiff --git a/tests/test_model_hub_retry_advice.py b/tests/test_model_hub_retry_advice.pyindex 0b047260d..a48aeb703 100644--- a/tests/test_model_hub_retry_advice.py+++ b/tests/test_model_hub_retry_advice.py@@ -296,22 +296,23 @@ async def test_connection_failure_has_no_response_receipt_or_retry_advice() -> N@pytest.mark.parametrize("protocol", WIRE)async def test_local_registration_failure_keeps_its_identity_with_http_receipt(protocol: str) -> None:+ message = "unknown provider for model retry-advice/model-a"+ # CLIProxyAPI's local routing rejection, rebuilt as a Claude error on /v1/messages.+ body = (+ {"type": "error", "error": {"type": "invalid_request_error", "message": message}}+ if protocol == "anthropic"+ else {"error": {"message": message, "type": "invalid_request_error", "code": "model_not_found", "param": "model"}}+ )+async def respond(_request: web.Request) -> web.Response:- return web.json_response(- {- "type": "error",- "error": {"type": "api_error", "message": "unknown provider for model retry-advice/model-a"},- },- status=502,- headers={"Retry-After": "60"},- )+ return web.json_response(body, status=400, headers={"Retry-After": "60"})async with _engine(respond) as (client, requests):outcome, body = await _invoke(client, protocol, False)assert outcome.kind is RawOutcomeKind.NETWORK_ERRORassert outcome.error_code == "engine_down"- assert outcome.http_status == 502+ assert outcome.http_status == 400assert outcome.retry_after == "60"assert outcome.response_received_at is not Noneassert outcome.response_received_at.tzinfo is timezone.utcdiff --git a/tests/test_model_hub_runtime.py b/tests/test_model_hub_runtime.pyindex be85c33d8..ca99b5c48 100644--- a/tests/test_model_hub_runtime.py+++ b/tests/test_model_hub_runtime.py@@ -5773,56 +5773,64 @@ def test_engine_client_marks_loopback_stream_disconnect_as_engine_down(asyncio.run(run())+def _cpa_unknown_provider(protocol: str, routed_model: str, *, error_type: str = "invalid_request_error") -> dict:+ """CLIProxyAPI's body for a routed model it has not registered (handlers_routing.go)."""++ message = f"unknown provider for model {routed_model}"+ if protocol == "anthropic":+ return {"type": "error", "error": {"type": error_type, "message": message}}+ return {"error": {"message": message, "type": error_type, "code": "model_not_found", "param": "model"}}++@pytest.mark.parametrize(- (- "status",- "reported_model",- "expected_kind",- "expected_code",- "expected_reason",- ),+ ("protocol", "status", "body", "expected_kind", "expected_code", "expected_reason"),((- 502,- "source-fixture123/model-a",+ "anthropic",+ 400,+ _cpa_unknown_provider("anthropic", "source-fixture123/model-a"),RawOutcomeKind.NETWORK_ERROR,"engine_down",None,),(- 502,- "source-fixture123/model-b",+ "openai_chat",+ 400,+ _cpa_unknown_provider("openai_chat", "source-fixture123/model-a"),+ RawOutcomeKind.NETWORK_ERROR,+ "engine_down",+ None,+ ),+ (+ "anthropic",+ 400,+ _cpa_unknown_provider("anthropic", "source-fixture123/model-b"),RawOutcomeKind.HTTP_ERROR,+ "upstream_request_invalid",None,- "server_error",),(- 503,- "source-fixture123/model-a",+ "anthropic",+ 502,+ _cpa_unknown_provider("anthropic", "source-fixture123/model-a", error_type="api_error"),RawOutcomeKind.HTTP_ERROR,None,"server_error",),),+ ids=("anthropic", "openai_chat", "another_model", "older_engine_502"),)def test_engine_client_distinguishes_local_model_registration_failure(monkeypatch: pytest.MonkeyPatch,+ protocol: str,status: int,- reported_model: str,+ body: dict,expected_kind: RawOutcomeKind,expected_code: str | None,expected_reason: str | None,) -> None:async def run() -> None:- payload = json.dumps(- {- "type": "error",- "error": {- "type": "api_error",- "message": f"unknown provider for model {reported_model}",- },- }- ).encode()+ payload = json.dumps(body).encode()class Content:reads = 0@@ -5856,7 +5864,7 @@ def test_engine_client_distinguishes_local_model_registration_failure(source = SourceRecord(source_id="src_fixture123",vendor="custom",- protocol="anthropic",+ protocol=protocol,base_url="https://api.example.test/v1",credential_ref="cred_fixture123",allowed_origins=(),@@ -5875,7 +5883,6 @@ def test_engine_client_distinguishes_local_model_registration_failure(decision = classify_outcome(outcome)assert outcome.kind is expected_kind- assert outcome.error_code == expected_codeassert decision.error_code == expected_codeassert decision.reason == expected_reasondiff --git a/vibe/model_hub_runtime/client.py b/vibe/model_hub_runtime/client.pyindex 98e7b2314..dc8873099 100644--- a/vibe/model_hub_runtime/client.py+++ b/vibe/model_hub_runtime/client.py@@ -564,7 +564,8 @@ class EngineClient:observed_payload = ProtocolObservation()finally:error_body.close()- if response.status == 502 and _is_local_model_registration_failure(+ if _is_local_model_registration_failure(+ response.status,payload,routed_model=routed_model,):@@ -574,7 +575,7 @@ class EngineClient:model_id=model_id,http_status=response.status,error_code="engine_down",- message="engine rejected its registered routed model",+ message="engine has not registered the routed model",)response.close()await session.close()@@ -1301,27 +1302,36 @@ def _project_model_inventory_before_deadline(def _is_local_model_registration_failure(+ status: int,payload: bytes,*,routed_model: str,) -> bool:- """Identify CLIProxyAPI's local pre-egress model registry rejection."""+ """Identify CLIProxyAPI's local pre-egress model registry rejection.++ CLIProxyAPI (sdk/api/handlers/handlers_routing.go at c404af96 and in v8)+ answers a model it has not registered with 400+ ``{"error":{"message":"unknown provider for model <prefix>/<model>",+ "type":"invalid_request_error","code":"model_not_found","param":"model"}}``;+ its Claude surface rebuilds that as ``{"type":"error","error":{"type":+ "invalid_request_error","message":...}}``. The routed model is Avibe's own+ ``<prefix>/<model>``, so the exact message names a local registration gap,+ not an upstream rejection.+ """+ if status != 400:+ return Falsetry:decoded = json.loads(payload)except (json.JSONDecodeError, UnicodeDecodeError):return False- if (- not isinstance(decoded, dict)- or "type" not in decoded- or decoded["type"] != "error"- ):+ if not isinstance(decoded, dict) or ("type" in decoded and decoded["type"] != "error"):return Falseerror = decoded.get("error")error_type, _, _ = _raw_error_fields(payload)return (isinstance(error, dict)- and error_type == "api_error"+ and error_type == "invalid_request_error"and error.get("message") == f"unknown provider for model {routed_model}")