Skip to content

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
gtardif:fix_openai_tool_call_params
Open

Fix schema conversion for OpenAI Responses API strict mode - Fixes tool calls with gpt-4.1-nano#2168
gtardif wants to merge 1 commit intodocker:mainfrom
gtardif:fix_openai_tool_call_params

Conversation

@gtardif
Copy link
Contributor

@gtardif gtardif commented Mar 19, 2026

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

Also manually tested too calls with openai/gpt-4o-mini and openai/gpt-4o

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>
@gtardif gtardif requested a review from a team as a code owner March 19, 2026 07:59
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: false for all object types as required by OpenAI Responses API strict mode

The test coverage adequately validates the core functionality for union type handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant