microsoft / microsoft/semantic-kernel

OpenAIPromptExecutionSettings.ExtraBody duplicates tools JSON property when setting nested object for web search tool

Open
#14,156 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.