Skip to content

[BUG] Azure.AI.OpenAI - Adding Tools to ChatCompletionOptions disables content filtering #57358

@Mako217

Description

@Mako217

Library name and version

Azure.AI.OpenAI 2.9.0-beta.1

Describe the bug

When you send a request that should be filtered by content filter to AzureOpenAIClient, but you include any tools in the ChatCompletionOptions it doesn't get filtered. Just removing the tools and asking the same prompt makes filtering work again.
An important note is that it didn't start failing after a library upgrade, but just randomly started failing around 18th or 19th of March 2026. At that time I was using Azure.AI.OpenAI 2.2.0-beta.4, but after upgrading to the latest version it still doesn't work.

Expected behavior

CompleteChatAsync and CompleteChatStreamingAsync methods return System.ClientModel.ClientResultException: HTTP 400 (content_filter) when asked a question that should be filtered out.

Actual behavior

LLM responds that it's sorry that it can't answer. However the filter doesn't trigger and an exception isn't thrown.

Reproduction Steps

AzureOpenAIClient openAiClient = new AzureOpenAIClient(/*endpoint, credential*/);
ChatTool getTestTool = ChatTool.CreateFunctionTool(
    functionName: "test",
    functionDescription: "Test tool",
    functionParameters: BinaryData.FromObjectAsJson(new
        {
            Type = "object",
            Properties = new
            {

            },
            Required = new[] { "" },
        },
        new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }
    )
);

List<ChatMessage> messages =
[
    new UserChatMessage(/*A prompt that should be filtered here*/)
];

ChatCompletionOptions options = new()
{
    Tools = { getTestTool }
};

var deploymentName = "gpt-4o";
var chatClient = openAiClient.GetChatClient(deploymentName);
var response =  await chatClient.CompleteChatAsync(messages, options);
Console.WriteLine(response.Value.Content[0].Text);

In this case the prompt won't get filtered out even if user asks questions related to self harm or illegal activities. However if you just comment out the Tools = { getTestTool } from ChatCompletionOptions initialization it will filter correctly and throws ClientResultException as expected.

Environment

I'm using gpt-4o model version 2024-11-20, but I checked it also on gpt-5.2 version 2025-12-11 and same thing happens

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue is related to a non-management packageOpenAIService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions