diff --git a/backend/app/services/model_routing.py b/backend/app/services/model_routing.py index e59bc71..04899e1 100644 --- a/backend/app/services/model_routing.py +++ b/backend/app/services/model_routing.py @@ -32,10 +32,8 @@ "tool result", ] -# Routing failures (OpenRouter malformed 200) produce "api error" in the CLI prefix. -# "malformed response" / "empty response" are specific message fragments for the same failure mode. +# "malformed response" / "empty response" are specific message fragments for the model routing failure mode. _MODEL_ROUTING_FAILURE_PATTERNS = [ - "api error", "malformed response", "empty response", ] diff --git a/backend/test/test_classify_error.py b/backend/test/test_classify_error.py index 234216f..0b5788a 100644 --- a/backend/test/test_classify_error.py +++ b/backend/test/test_classify_error.py @@ -31,8 +31,9 @@ def test_api_error_prefix(self): msg = "API Error: API returned an empty or malformed response (HTTP 200) — check for a proxy or gateway intercepting the request" assert classify_error(msg) == AgentErrorType.MODEL_ROUTING_FAILURE - def test_api_error_case_insensitive(self): - assert classify_error("api error: something went wrong") == AgentErrorType.MODEL_ROUTING_FAILURE + def test_api_error_alone_no_longer_classifies(self): + # "api error" was removed from the pattern list — too broad, matched genuine HTTP errors. + assert classify_error("api error: something went wrong") is None def test_malformed_response_pattern(self): assert classify_error("malformed response received from upstream") == AgentErrorType.MODEL_ROUTING_FAILURE @@ -80,7 +81,7 @@ def test_status_200_does_not_exclude_routing_failure(self): assert classify_error(msg, api_error_status=200) == AgentErrorType.MODEL_ROUTING_FAILURE def test_status_below_400_does_not_exclude(self): - msg = "API Error: redirect issue" + msg = "API Error: malformed response, redirect issue" assert classify_error(msg, api_error_status=301) == AgentErrorType.MODEL_ROUTING_FAILURE