fix(retain): honor retain strict-schema flag - #3653
Closed
kamilfurtak wants to merge 2 commits into
Closed
Conversation
This was referenced Aug 19, 2026
kamilfurtak
force-pushed
the
agent/retain-strict-schema-flag
branch
2 times, most recently
from
August 19, 2026 20:51
9b631dc to
91b6213
Compare
kamilfurtak
force-pushed
the
agent/retain-strict-schema-flag
branch
from
August 19, 2026 20:54
91b6213 to
0fcdc78
Compare
Author
|
Superseded by #3656, which combines this with the other output-retry fix into a single reviewable change. No content was dropped. |
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.
Summary
Use the retain-scoped strict-schema flag consistently when building the Batch API request body.
Reproduction
Hindsight 0.9.1 can resolve:
The batch retain path used the global flag to choose between
strict_json_schema()and the ordinary Pydantic schema, but used the retain flag for the request'sstrictfield. That sentstrict: truewith a schema built through the non-strict path, so retain-specific strict-subset constraints were absent from the final request body.Impact
Retain requests could advertise strict structured output while omitting constraints that were present in the retain strict schema, including array bounds used by downstream safeguards. The batch path could therefore disagree with the streaming retain path.
Fix
Resolve
llm_strict_schema_retainonce and use it for both:strict_json_schema()versus the regular schema;strictfield.This preserves the intended per-operation override and does not change reflect or consolidation behavior.
Testing
tests/test_fact_extraction_retry.pyandtests/test_strict_json_schema.py: 29 passed.global=false / retain=trueselects the strict schema and sendsstrict: true;global=true / retain=falsedoes not callstrict_json_schema()and sendsstrict: false.Found while diagnosing Hindsight 0.9.1 retain behavior. This PR is intentionally separate from the nested-conversation splitter fix and the maxItems/saturation changes.