Fix schema conversion for OpenAI Responses API strict mode - Fixes tool calls with gpt-4.1-nano#2168
Open
gtardif wants to merge 1 commit intodocker:mainfrom
Open
Fix schema conversion for OpenAI Responses API strict mode - Fixes tool calls with gpt-4.1-nano#2168gtardif wants to merge 1 commit intodocker:mainfrom
gtardif wants to merge 1 commit intodocker:mainfrom
Conversation
The Responses API with strict=true requires all object-type schemas to have additionalProperties: false, even when type is an array like ["object", "null"]. This fix ensures that: 1. All object types (including union types) get additionalProperties: false 2. Existing object schemas in additionalProperties are preserved 3. Free-form map[string]any properties (like user_prompt's schema field) now properly have additionalProperties: false instead of true Fixes the error when using gpt-4.1-nano: 'additionalProperties' is required to be supplied and to be false Assisted-By: docker-agent Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
No bugs found in the changed code. The implementation correctly handles:
- Type detection for union types like
["object", "null"]across multiple formats (string, []any, []string) - Proper preservation of existing object schemas in
additionalProperties - Setting
additionalProperties: falsefor all object types as required by OpenAI Responses API strict mode
The test coverage adequately validates the core functionality for union type handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Responses API with strict=true requires all object-type schemas to have additionalProperties: false, even when type is an array like ["object", "null"].
This fix ensures that:
Fixes the error when using gpt-4.1-nano:
'additionalProperties' is required to be supplied and to be false
Assisted-By: docker-agent
Also manually tested too calls with openai/gpt-4o-mini and openai/gpt-4o