alibaba/page-agent · warning · InvokeError

CONTENT_FILTER

CONTENT_FILTER

Error message

Content filtered by safety system

What it means

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.

Source

Thrown at packages/llms/src/OpenAIClient.ts:161

		if (!choice) {
			throw new InvokeError(InvokeErrorTypes.INVALID_SCHEMA, 'No choices in response', data)
		}

		// Check finish_reason
		switch (choice.finish_reason) {
			case 'tool_calls':
			case 'function_call': // gemini
			case 'stop': // some models use this even with tool calls
				break
			case 'length':
				throw new InvokeError(
					InvokeErrorTypes.CONTEXT_LENGTH,
					'Response truncated: max tokens reached',
					undefined,
					data
				)
			case 'content_filter':
				throw new InvokeError(
					InvokeErrorTypes.CONTENT_FILTER,
					'Content filtered by safety system',
					undefined,
					data
				)
			default:
				throw new InvokeError(
					InvokeErrorTypes.INVALID_SCHEMA,
					`Unexpected finish_reason: ${choice.finish_reason}`,
					undefined,
					data
				)
		}

		// Apply normalizeResponse if provided (for fixing format issues automatically)
		const normalizedData = options?.normalizeResponse ? options.normalizeResponse(data) : data
		const normalizedChoice = (normalizedData as any).choices?.[0]

View on GitHub (pinned to d02db1ee7c)

Solutions

  1. Inspect the attached response — many providers identify which category triggered the filter
  2. Rewrite/rephrase the prompt to avoid flagged terms, or reduce explicit detail in sensitive topics
  3. On Azure, adjust content filter configurations on the deployment (where policy allows)
  4. Fall back to a different model/deployment with different filtering, or degrade gracefully instead of retrying — retrying the same prompt usually re-triggers it
Defensive patterns

Strategy: fallback

Type guard

const isContentFilterError = (e: unknown): e is InvokeError =>
  e instanceof InvokeError && e.code === 'CONTENT_FILTER'

Try / catch

try {
  return await client.invoke(req)
} catch (e) {
  if (isContentFilterError(e)) {
    return fallbackResponse // do NOT retry the same prompt — it will re-trigger
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.


AI-assisted analysis of alibaba/page-agent@d02db1ee7c (2026-08-28). Data as JSON: /api/errors/121ad28dd166562a. Report an issue: GitHub.