Skip to content

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

Description

@andrejpin2

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"
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions