Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(embedding): keep failover retryable when only some creds auth-fail (#2916) (#2945)
Kevin Hou433bcacc1700
diff --git a/openviking/utils/model_retry.py b/openviking/utils/model_retry.pyindex 8dd9bcbc1..5361f5a4d 100644--- a/openviking/utils/model_retry.py+++ b/openviking/utils/model_retry.py@@ -8,6 +8,8 @@ import threadingimport timefrom typing import Awaitable, Callable, TypeVar+from openviking.utils.exceptions import AllCredentialsFailedError+logger = logging.getLogger(__name__)T = TypeVar("T")@@ -147,7 +149,19 @@ def classify_api_error(error: Exception) -> str:- ``quota_exceeded`` is checked before ``transient`` because quota errorstypically include "429" / "TooManyRequests" which would otherwise matchthe transient category.+ - an aggregated ``AllCredentialsFailedError`` is classified from its+ per-credential classes, not its concatenated message."""+ if isinstance(error, AllCredentialsFailedError):+ classes = [ec for (_cid, ec, _exc, _idx) in error.errors if ec]+ if ERROR_CLASS_TRANSIENT in classes:+ return ERROR_CLASS_TRANSIENT+ if ERROR_CLASS_QUOTA_EXCEEDED in classes:+ return ERROR_CLASS_QUOTA_EXCEEDED+ if classes and all(ec == ERROR_CLASS_AUTH for ec in classes):+ return ERROR_CLASS_AUTH+ return ERROR_CLASS_UNKNOWN+for exc in (error, getattr(error, "__cause__", None)):if exc is not None and isinstance(exc, _PERMANENT_IO_ERRORS):return ERROR_CLASS_PERMANENTdiff --git a/tests/unit/test_model_retry.py b/tests/unit/test_model_retry.pyindex 016fbf460..66246eddf 100644--- a/tests/unit/test_model_retry.py+++ b/tests/unit/test_model_retry.py@@ -4,6 +4,7 @@import pytest+from openviking.utils.exceptions import AllCredentialsFailedErrorfrom openviking.utils.model_retry import (ERROR_CLASS_AUTH,ERROR_CLASS_CONTENT_SAFETY,@@ -21,6 +22,16 @@ def test_classify_api_error_recognizes_request_burst_too_fast():assert classify_api_error(RuntimeError("RequestBurstTooFast")) == ERROR_CLASS_TRANSIENT+def test_classify_all_credentials_failed_prefers_transient_over_auth():+ err = AllCredentialsFailedError(+ [+ ("cred-a", ERROR_CLASS_AUTH, RuntimeError("401 Unauthorized"), 0),+ ("cred-b", ERROR_CLASS_TRANSIENT, RuntimeError("500 server error"), 1),+ ]+ )+ assert classify_api_error(err) == ERROR_CLASS_TRANSIENT++def test_retry_sync_retries_transient_error_until_success():attempts = {"count": 0}