microsoft / microsoft/semantic-kernel
OpenAIPromptExecutionSettings.ExtraBody duplicates tools JSON property when setting nested object for web search tool
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 28.6k
- Forks
- 4.8k
- Avg merge
- 14h 13m
- Merged PRs (30d)
- 18
Description
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"
}
]
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the request with OpenAIPromptExecutionSettings.ExtraBody using the provided tools examples, then trace how ExtraBody is applied during request serialization. Done means the resulting request contains a single tools property and the existing behavior remains valid for the shown input variants.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100