Summary
I’m trying to enable OpenAI web search for a newer model by adding a tools entry through OpenAIPromptExecutionSettings.ExtraBody.
However, any ExtraBody patch targeting tools causes the final request body to contain duplicate top-level tools properties, which results in a bad request.
Example code
var settings = new OpenAIPromptExecutionSettings
{
ExtraBody = new Dictionary<string, object?>
{
["tools"] = new[]
{
new { type = "web_search" }
}
}
};
I also tried JSONPath-style keys:
settings.ExtraBody = new Dictionary<string, object?>
{
["$.tools"] = new[]
{
new { type = "web_search" }
}
};
And nested-path patching:
settings.ExtraBody = new Dictionary<string, object?>
{
["$.tools[0].type"] = "web_search"
};
Actual request body
All approaches produce duplicate tools fields in the serialized request body, for example:
{
"tools": [
{
"type": "web_search"
}
],
"tools": [
{
"type": "web_search"
}
]
}
Summary
I’m trying to enable OpenAI web search for a newer model by adding a tools entry through OpenAIPromptExecutionSettings.ExtraBody.
However, any ExtraBody patch targeting tools causes the final request body to contain duplicate top-level tools properties, which results in a bad request.
Example code
I also tried JSONPath-style keys:
And nested-path patching:
Actual request body
All approaches produce duplicate tools fields in the serialized request body, for example:
{ "tools": [ { "type": "web_search" } ], "tools": [ { "type": "web_search" } ] }