Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions backend/app/services/model_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
7 changes: 4 additions & 3 deletions backend/test/test_classify_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down