fix: recursively apply strict schema constraints for tools_strict=True#11232
Merged
sjrl merged 6 commits intodeepset-ai:mainfrom May 11, 2026
Merged
fix: recursively apply strict schema constraints for tools_strict=True#11232sjrl merged 6 commits intodeepset-ai:mainfrom
sjrl merged 6 commits intodeepset-ai:mainfrom
Conversation
The existing code only set additionalProperties: false at the top level of tool parameter schemas. OpenAI strict mode requires it recursively on all nested objects, $defs, array items, and anyOf/oneOf/allOf branches. Add _make_schema_strict() that walks the schema recursively and sets additionalProperties: false + required on every object. Replace the single-line top-level-only fix in _prepare_api_call. 10 new tests including a 4-level-deep ComponentTool-style schema. Closes deepset-ai#9411
|
@ArkaD171717 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
Fixed ruff formatting and added release note |
Member
|
@sjrl, could you please take a look at this PR? |
Contributor
Author
|
Hey I noticed the reno check failed, it was a UID collision on the release note filename and i pushed the fix. |
sjrl
reviewed
May 4, 2026
sjrl
reviewed
May 4, 2026
sjrl
reviewed
May 4, 2026
sjrl
reviewed
May 4, 2026
…gration test - single backticks in docstring instead of double - link to OpenAI structured outputs docs - all unit tests use full dict comparison instead of checking individual keys - added integration test with complex schema through _prepare_api_call
Contributor
Author
|
Pushed fix for backtick formatting changed to full dict comparisons, added the schemas link in the docstring and added a harder integration test that wouldve failed on the old version |
- test_prepare_api_call_strict_component_tool verifies ComponentTool with ChatMessage params gets all nested $defs strictified - test_live_run_strict_nested_tool hits the OpenAI API with a nested tool schema under tools_strict=True to confirm acceptance
sjrl
reviewed
May 8, 2026
sjrl
reviewed
May 8, 2026
sjrl
reviewed
May 8, 2026
Dropped test_oneof (branch covered by test_anyof), test_prepare_api_call_strict_complex_tool (superseded by integration test), and test_prepare_api_call_strict_component_tool (complex cases already covered). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
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.
tools_strict=Truewas only settingadditionalProperties: falseat the toplevel of tool parameter schemas
OpenAI's strict mode rejects anything with nested objects that don't also have
additionalProperties: falseand a completerequiredlistSo any tool with nested params (like a ComponentTool wrapping a component that
takes ChatMessage-shaped input) would fail at the API
Adds
_make_schema_strict()that walks the schema recursively: nestedproperties,
$defs, arrayitems,anyOf/oneOf/allOfbranchesSets the strict constraints at every level
Replaces the single-line top-level-only fix in
_prepare_api_callReturns a copy, doesn't mutate the original schema dict
10 new tests including a 4-level-deep ComponentTool-style schema
All 37 existing tests still pass
Closes #9411