Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(retry): classify Ark "timed out" and bare TimeoutError as transient (#6102)

t0sakicc9dff6e8744
diff --git a/openviking/utils/model_retry.py b/openviking/utils/model_retry.py
index 5fe9a9a18..f8a8584d3 100644
--- a/openviking/utils/model_retry.py
+++ b/openviking/utils/model_retry.py
@@ -182,6 +182,8 @@ TRANSIENT_API_ERROR_PATTERNS = (
"ratelimit",
"requestbursttoofast",
"timeout",
+ # Ark / OpenAI SDK read timeouts say "Request timed out."
+ "timed out",
"connectionerror",
"connection refused",
"connection reset",
@@ -296,6 +298,12 @@ def classify_api_error(error: Exception) -> str:
if pattern in text_lower:
return ERROR_CLASS_QUOTA_EXCEEDED
+ # Bare timeouts often carry no message; asyncio.TimeoutError is a distinct
+ # class on Python 3.10.
+ for exc in (error, error.__cause__):
+ if isinstance(exc, (TimeoutError, asyncio.TimeoutError)):
+ return ERROR_CLASS_TRANSIENT
+
for text in texts:
text_lower = text.lower()
text_compact = text_lower.replace(" ", "")
diff --git a/tests/unit/test_model_retry.py b/tests/unit/test_model_retry.py
index 35945c47c..1bef4a9ea 100644
--- a/tests/unit/test_model_retry.py
+++ b/tests/unit/test_model_retry.py
@@ -2,6 +2,8 @@
# SPDX-License-Identifier: Apache-2.0
"""Tests for shared model retry helpers."""
+import asyncio
+
import httpx
import openai
import pytest
@@ -71,6 +73,21 @@ def test_classify_api_error_recognizes_request_burst_too_fast():
assert classify_api_error(RuntimeError("RequestBurstTooFast")) == ERROR_CLASS_TRANSIENT
+def test_classify_api_error_recognizes_timed_out_message():
+ assert classify_api_error(RuntimeError("Request timed out.")) == ERROR_CLASS_TRANSIENT
+
+
[email protected]("error_type", [TimeoutError, asyncio.TimeoutError])
[email protected]("wrapped", [False, True])
+def test_classify_api_error_treats_bare_timeout_as_transient(error_type, wrapped):
+ error = error_type()
+ if wrapped:
+ wrapper = RuntimeError("vlm call failed")
+ wrapper.__cause__ = error
+ error = wrapper
+ assert classify_api_error(error) == ERROR_CLASS_TRANSIENT
+
+
class _ProviderError(RuntimeError):
def __init__(self, *, status_code=None, error_code=None, code=None, body=None):
super().__init__("provider request failed")