The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(agent): classify CommandCode 'Content Exists Risk' 400 as a content-policy block
liuhao1024d4f88f39eef5
diff --git a/agent/error_classifier.py b/agent/error_classifier.pyindex 293b6c42bcb..9127cede3ae 100644--- a/agent/error_classifier.py+++ b/agent/error_classifier.py@@ -343,13 +343,15 @@ _PROVIDER_POLICY_BLOCKED_PATTERNS = (# Per-prompt safety-filter blocks: deterministic for the unchanged request, so# fallback immediately. Each phrase is verbatim from one provider (Codex cyber# flags #18028, OpenAI moderation, Anthropic safety, Azure token, MiniMax-# #32421) — never a generic word like "policy" that collides with billing/auth.+# #32421, CommandCode gateway moderation #115218) — never a generic word like+# "policy" that collides with billing/auth.# "content_filter" deliberately excludes the space variant seen in echoed config._CONTENT_POLICY_BLOCKED_PATTERNS = ("flagged for possible cybersecurity risk", "trusted access for cyber","violates our usage policies", "violates openai's usage policies", "your request was flagged by","prompt was flagged by our safety", "responses cannot be generated due to safety","content_filter", "responsibleaipolicyviolation", "new_sensitive",+ "content exists risk",)# Auth patterns (non-status-code signals).diff --git a/tests/agent/test_error_classifier.py b/tests/agent/test_error_classifier.pyindex 5c0f941b150..74c75e04a94 100644--- a/tests/agent/test_error_classifier.py+++ b/tests/agent/test_error_classifier.py@@ -745,6 +745,38 @@ class TestClassifyApiError:assert result.should_fallback is Trueassert result.should_compress is False+ def test_400_content_exists_risk_commandcode_moderation(self):+ # CommandCode gateway (OpenAI-compatible aggregator fronting DeepSeek)+ # rejects filtered prompts with HTTP 400 "Content Exists Risk" and a+ # nested param envelope marking isRetryable=false — deterministic for+ # the unchanged request, so the recovery is the fallback chain, not a+ # same-provider retry. Without the pattern the 400 fell through to+ # format_error and the surfaced copy blamed a malformed request. See+ # #115218.+ body = {+ "error": {+ "message": "Content Exists Risk",+ "type": "AI_APICallError",+ "param": {+ "error": "Content Exists Risk", "statusCode": 400,+ "name": "AI_APICallError", "message": "Content Exists Risk",+ "isRetryable": False, "type": "AI_APICallError",+ },+ }+ }+ e = MockAPIError(+ "Error code: 400 - {'error': {'message': 'Content Exists Risk'}}",+ status_code=400,+ body=body,+ )+ result = classify_api_error(+ e, provider="commandcode", model="deepseek/deepseek-v4.1-flash"+ )+ assert result.reason == FailoverReason.content_policy_blocked+ assert result.retryable is False+ assert result.should_fallback is True+ assert result.should_compress is False+