Skip to content

fix(retain): honor retain strict-schema flag - #3653

Closed
kamilfurtak wants to merge 2 commits into
vectorize-io:mainfrom
kamilfurtak:agent/retain-strict-schema-flag
Closed

fix(retain): honor retain strict-schema flag#3653
kamilfurtak wants to merge 2 commits into
vectorize-io:mainfrom
kamilfurtak:agent/retain-strict-schema-flag

Conversation

@kamilfurtak

@kamilfurtak kamilfurtak commented Aug 19, 2026

Copy link
Copy Markdown

Summary

Use the retain-scoped strict-schema flag consistently when building the Batch API request body.

Reproduction

Hindsight 0.9.1 can resolve:

llm_strict_schema        = false
llm_strict_schema_retain = true

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's strict field. That sent strict: true with 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_retain once and use it for both:

  • selecting strict_json_schema() versus the regular schema;
  • the JSON-schema request body's strict field.

This preserves the intended per-operation override and does not change reflect or consolidation behavior.

Testing

  • tests/test_fact_extraction_retry.py and tests/test_strict_json_schema.py: 29 passed.
  • Regression coverage includes both override directions:
    • global=false / retain=true selects the strict schema and sends strict: true;
    • global=true / retain=false does not call strict_json_schema() and sends strict: false.
  • Ruff check and format check passed.

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.

@kamilfurtak
kamilfurtak force-pushed the agent/retain-strict-schema-flag branch 2 times, most recently from 9b631dc to 91b6213 Compare August 19, 2026 20:51
@kamilfurtak
kamilfurtak force-pushed the agent/retain-strict-schema-flag branch from 91b6213 to 0fcdc78 Compare August 19, 2026 20:54
@kamilfurtak

Copy link
Copy Markdown
Author

Superseded by #3656, which combines this with the other output-retry fix into a single reviewable change. No content was dropped.

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