-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
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