{"record":{"id":"802a24529748c4c8","repo":"microsoft/autogen","slug":"the-content-is-filtered-because-its-potential-risk-802a24","errorCode":null,"errorMessage":"The content is filtered because its potential risk. Please try another input.","messagePattern":"The content is filtered because its potential risk\\. Please try another input\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.OpenAI.V1/Middleware/OpenAIChatRequestMessageConnector.cs","lineNumber":131,"sourceCode":"        {\n            return new ToolCallMessageUpdate(currentToolName, functionArgumentsUpdate, from: update.From);\n        }\n        else if (update.Content.ToolCallUpdate is StreamingFunctionToolCallUpdate tooCallUpdate && currentToolName is string)\n        {\n            return new ToolCallMessageUpdate(tooCallUpdate.Name ?? currentToolName, tooCallUpdate.ArgumentsUpdate, from: update.From);\n        }\n        else\n        {\n            return null;\n        }\n    }\n\n    private IMessage PostProcessChatCompletions(IMessage<ChatCompletions> message)\n    {\n        // throw exception if prompt filter results is not null\n        if (message.Content.Choices[0].FinishReason == CompletionsFinishReason.ContentFiltered)\n        {\n            throw new InvalidOperationException(\"The content is filtered because its potential risk. Please try another input.\");\n        }\n\n        return PostProcessChatResponseMessage(message.Content.Choices[0].Message, message.From);\n    }\n\n    private IMessage PostProcessChatResponseMessage(ChatResponseMessage chatResponseMessage, string? from)\n    {\n        var textContent = chatResponseMessage.Content;\n        if (chatResponseMessage.FunctionCall is FunctionCall functionCall)\n        {\n            return new ToolCallMessage(functionCall.Name, functionCall.Arguments, from)\n            {\n                Content = textContent,\n            };\n        }\n\n        if (chatResponseMessage.ToolCalls.Where(tc => tc is ChatCompletionsFunctionToolCall).Any())\n        {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.OpenAI.V1/Middleware/OpenAIChatRequestMessageConnector.cs#L113-L149","documentation":"Thrown in PostProcessChatCompletions when the first choice's FinishReason equals CompletionsFinishReason.ContentFiltered. Azure OpenAI's content filter flagged either the prompt or the completion as potentially unsafe, so the model returned no usable content. The connector surfaces this as an explicit InvalidOperationException instead of returning an empty assistant message.","triggerScenarios":"Calling an agent backed by OpenAIChatRequestMessageConnector (strictMode true or false) with prompts containing violence, hate, self-harm, sexual, or jailbreak-adjacent content, or when the deployment's content filter is configured at a strict level; the API succeeds but returns finish_reason 'content_filter'.","commonSituations":"Strict content-filter configurations on an Azure OpenAI deployment; prompt-injection testing; safety-eval workloads that intentionally probe unsafe content; prompts copied from moderation test suites.","solutions":["Rephrase or sanitize the input prompt that triggered the filter","Request a content_filter amendment or adjust the deployment's filter severity in Azure OpenAI Studio","Catch InvalidOperationException and branch to a moderation message or fallback flow","If using group chat, wrap this agent so a filtered reply doesn't kill the whole conversation loop"],"exampleFix":"// before\nvar reply = await agent.SendAsync(\"<prompt that trips the filter>\"); // throws\n\n// after\ntry\n{\n    var reply = await agent.SendAsync(prompt);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"content is filtered\"))\n{\n    // log and continue conversation with a safer prompt\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (InvalidOperationException ex) when (ex.Message.Contains(\"content is filtered\")) { /* sanitize prompt and retry once, or return moderation message */ }","preventionTips":["Pre-screen prompts with a moderation endpoint for user-generated input","Know your deployment's filter configuration","Wrap agent calls so one filtered reply doesn't crash a group chat loop"],"tags":["autogen","dotnet","azure-openai","content-filter","moderation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}