Skip to content

[Microsoft.Extensions.AI.OpenAI] Tool schema with object-valued additionalProperties throws JsonException (ToolJson.AdditionalProperties typed as bool) #7540

Closed

Description

@scottt732

Package: Microsoft.Extensions.AI.OpenAI 10.6.0

Summary

OpenAIClientExtensions.ToOpenAIFunctionParameters deserializes every tool's schema via element.Deserialize(OpenAIJsonContext.Default.ToolJson), and the internal ToolJson type declares:

[JsonPropertyName("additionalProperties")] public bool AdditionalProperties { get; set; }

JSON Schema permits additionalProperties to be either a boolean or a sub-schema object. Any tool whose schema uses the object form throws:

System.Text.Json.JsonException: The JSON value could not be converted to System.Boolean. Path: $.additionalProperties | LineNumber: 0 | BytePositionInLine: 261.

…aborting the request. This happens for every function tool regardless of strict mode — ToOpenAIFunctionParameters deserializes into ToolJson on both the strict-transformed and the raw-schema branch — and on both the Chat Completions (ToOpenAIChatTool) and Responses/Assistants tool-conversion paths.

Repro

Create an AIFunction whose JsonSchema is:

{ "type": "object", "properties": { "labels": { "type": "object" } }, "additionalProperties": { "type": "string" } }

…and pass it as a tool to an OpenAI IChatClient. The request build throws the JsonException above. This schema shape is common in OpenAPI/MCP-derived tools (e.g. map/dictionary parameters render additionalProperties as a sub-schema).

Expected

The object form of additionalProperties is accepted (handled or normalized), not a hard JsonException.

Suggested fix

Type ToolJson.AdditionalProperties so it tolerates both forms (e.g. JsonElement, or bool? with a converter), or normalize the schema before deserialization.

Workaround

Wrap the IChatClient in a DelegatingChatClient that recursively coerces object-valued additionalProperties to false in each tool's schema before it reaches the bridge.

Activity

  1. added
    bugThis issue describes a behavior which is not expected - a bug.
    and removed on Jun 8, 2026
  2. jozkee commented on Jun 10, 2026

    @jozkee
    Member

    @scottt732 thanks, this should be fixed in 10.7.0.

  3. locked and limited conversation to collaborators on Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-aiMicrosoft.Extensions.AI librariesbugThis issue describes a behavior which is not expected - a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions