You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Microsoft.Extensions.AI.OpenAI] Tool schema with object-valued additionalProperties throws JsonException (ToolJson.AdditionalProperties typed as bool) #7540
OpenAIClientExtensions.ToOpenAIFunctionParameters deserializes every tool's schema via element.Deserialize(OpenAIJsonContext.Default.ToolJson), and the internal ToolJson type declares:
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.
…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
jozkee commentedon Jun 10, 2026
@scottt732 thanks, this should be fixed in 10.7.0.