{"record":{"id":"121ad28dd166562a","repo":"alibaba/page-agent","slug":"content-filter","errorCode":"CONTENT_FILTER","errorMessage":"Content filtered by safety system","messagePattern":"Content filtered by safety system","errorType":"exception","errorClass":"InvokeError","httpStatus":null,"severity":"warning","filePath":"packages/llms/src/OpenAIClient.ts","lineNumber":161,"sourceCode":"\t\tif (!choice) {\n\t\t\tthrow new InvokeError(InvokeErrorTypes.INVALID_SCHEMA, 'No choices in response', data)\n\t\t}\n\n\t\t// Check finish_reason\n\t\tswitch (choice.finish_reason) {\n\t\t\tcase 'tool_calls':\n\t\t\tcase 'function_call': // gemini\n\t\t\tcase 'stop': // some models use this even with tool calls\n\t\t\t\tbreak\n\t\t\tcase 'length':\n\t\t\t\tthrow new InvokeError(\n\t\t\t\t\tInvokeErrorTypes.CONTEXT_LENGTH,\n\t\t\t\t\t'Response truncated: max tokens reached',\n\t\t\t\t\tundefined,\n\t\t\t\t\tdata\n\t\t\t\t)\n\t\t\tcase 'content_filter':\n\t\t\t\tthrow new InvokeError(\n\t\t\t\t\tInvokeErrorTypes.CONTENT_FILTER,\n\t\t\t\t\t'Content filtered by safety system',\n\t\t\t\t\tundefined,\n\t\t\t\t\tdata\n\t\t\t\t)\n\t\t\tdefault:\n\t\t\t\tthrow new InvokeError(\n\t\t\t\t\tInvokeErrorTypes.INVALID_SCHEMA,\n\t\t\t\t\t`Unexpected finish_reason: ${choice.finish_reason}`,\n\t\t\t\t\tundefined,\n\t\t\t\t\tdata\n\t\t\t\t)\n\t\t}\n\n\t\t// Apply normalizeResponse if provided (for fixing format issues automatically)\n\t\tconst normalizedData = options?.normalizeResponse ? options.normalizeResponse(data) : data\n\t\tconst normalizedChoice = (normalizedData as any).choices?.[0]\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/alibaba/page-agent/blob/d02db1ee7c41f5315beda88bab2fe935c580f662/packages/llms/src/OpenAIClient.ts#L143-L179","documentation":"The model's output was blocked by the provider's safety system (finish_reason === 'content_filter') before any usable content was produced. The raw response is attached in details; there is no underlying cause object because this is a policy decision by the server, not a malfunction.","triggerScenarios":"invoke() where prompts or generated content trip the provider's moderation filter: disallowed content requests, benign prompts accidentally flagged (violence/medical/security topics), or strict enterprise content policies on Azure OpenAI content filters.","commonSituations":"Security research, pentesting, or healthcare/violence-adjacent agent tasks being flagged; Azure OpenAI default content filters blocking prompts; jailbreak-adjacent phrasing in system prompts; prompts copied from flagged web content.","solutions":["Inspect the attached response — many providers identify which category triggered the filter","Rewrite/rephrase the prompt to avoid flagged terms, or reduce explicit detail in sensitive topics","On Azure, adjust content filter configurations on the deployment (where policy allows)","Fall back to a different model/deployment with different filtering, or degrade gracefully instead of retrying — retrying the same prompt usually re-triggers it"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":"const isContentFilterError = (e: unknown): e is InvokeError =>\n  e instanceof InvokeError && e.code === 'CONTENT_FILTER'","tryCatchPattern":"try {\n  return await client.invoke(req)\n} catch (e) {\n  if (isContentFilterError(e)) {\n    return fallbackResponse // do NOT retry the same prompt — it will re-trigger\n  }\n  throw e\n}","preventionTips":["Catch CONTENT_FILTER separately and degrade gracefully rather than retrying","Rephrase sensitive-topic prompts to reduce filter triggers","On Azure, review deployment content-filter settings and log filter categories from e.details"],"tags":["content-filter","safety","finish-reason"],"backgroundTag":"content-filtered","analyzedSha":"d02db1ee7c41f5315beda88bab2fe935c580f662","analyzedAt":"2026-08-28T19:39:48.634Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}