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(models): classify SiliconFlow code 20015 embedding 400s as input-too-large (#4678)
now-ing90a618091330
diff --git a/openviking/utils/model_retry.py b/openviking/utils/model_retry.pyindex 35a089dce..7f12fbc9b 100644--- a/openviking/utils/model_retry.py+++ b/openviking/utils/model_retry.py@@ -89,6 +89,13 @@ INPUT_TOO_LARGE_PATTERNS = ("exceeds the max input length","is too large to process","expected maxlength",+ # SiliconFlow reports an oversized embedding input as a generic 400 whose+ # payload carries code 20015 ("The parameter is invalid") with no size+ # keyword in the message. Match the structured code field (both the dict+ # repr and the JSON string form) so the message is skipped instead of+ # arming the circuit breaker for the whole queue (#4676).+ "code': 20015",+ 'code": 20015',)PERMANENT_API_ERROR_PATTERNS = ("400",)diff --git a/tests/unit/test_model_retry.py b/tests/unit/test_model_retry.pyindex 4d246cd1e..95b41bb5b 100644--- a/tests/unit/test_model_retry.py+++ b/tests/unit/test_model_retry.py@@ -219,12 +219,39 @@ def test_quota_exceeded_case_insensitive():"'input (8525 tokens) is too large to process. increase the physical batch size ""(current batch size: 2048)', 'type': 'server_error'}}"),+ # SiliconFlow generic 400 with structured code 20015, dict-repr form (#4676)+ (+ "Error code: 400 - {'code': 20015, 'message': "+ "'The parameter is invalid. Please check again.', 'data': None}"+ ),+ # JSON string form+ 'Error code: 400 - {"code": 20015, "message": "The parameter is invalid."}',],)def test_classify_input_too_large_errors(message):assert classify_api_error(RuntimeError(message)) == ERROR_CLASS_INPUT_TOO_LARGE+def test_other_siliconflow_400_codes_stay_permanent():+ """Only code 20015 is reclassified; other SiliconFlow parameter errors+ (e.g. a bad model name) must remain permanent request-level failures."""+ error = RuntimeError(+ "Error code: 400 - {'code': 20012, 'message': 'Model not exists', 'data': None}"+ )+ assert classify_api_error(error) == ERROR_CLASS_PERMANENT+++def test_20015_inside_request_id_is_not_input_too_large():+ """A rate-limit error whose request ID happens to contain 20015 must not+ be misclassified as INPUT_TOO_LARGE."""+ error = RuntimeError(+ "Error code: 429 - {'error': {'code': 'TooManyRequests', "+ "'message': 'RPM limit exceeded', "+ "'request_id': '0217801248873024200158fe53d7c9130f34413480585e683685bc95'}}"+ )+ assert classify_api_error(error) == ERROR_CLASS_TRANSIENT++def test_retry_sync_does_not_retry_input_too_large():attempts = {"count": 0}