fix(auto-itemize): set strict=true on Anthropic json_schema (#1547)#1561
Merged
Conversation
…format Anthropic's OpenAI-compat layer rejected our schema with: response_format.json_schema.strict: Input should be True Per the diagnostic captured by the new error logging (PR #1558), Anthropic requires `strict: true` on the json_schema (where OpenAI treats it as optional). With strict mode, OpenAI's structured-outputs spec — which Anthropic mirrors — also imposes: 1. additionalProperties: false on every object node 2. EVERY property must be listed in `required` (optional fields use union-typed nulls: type: ['number', 'null']) Our `validateExtractedLines` already tolerates null on the optional fields, so the LLM emitting quantity: null instead of omitting the key is fine — the validator coerces null → undefined for the runtime ExtractedLine. Test updated to assert all three strict-mode invariants. Co-Authored-By: Claude backend-developer (Haiku 4.5) <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 2.7.0-beta.8 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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
After PR #1558 landed Anthropic-aware request shaping, the next 400 from Anthropic captured by the new error diagnostics was:
```
response_format.json_schema.strict: Input should be True
```
Anthropic's OpenAI-compat layer requires `strict: true` (where OpenAI treats it as optional). With strict mode, OpenAI's structured-outputs spec — which Anthropic mirrors — also imposes:
Our `validateExtractedLines` already tolerates `null` on optional fields, so the LLM emitting `quantity: null` instead of omitting the key is fine — the validator coerces null → undefined for the runtime `ExtractedLine`.
Fixes the only remaining blocker on Anthropic; OpenAI/Gemini/Ollama/generic profiles are untouched.
Test plan
🤖 Generated with Claude Code