Skip to content

fix(auto-itemize): set strict=true on Anthropic json_schema (#1547)#1561

Merged
steilerDev merged 1 commit into
betafrom
fix/1547-anthropic-strict-schema
May 23, 2026
Merged

fix(auto-itemize): set strict=true on Anthropic json_schema (#1547)#1561
steilerDev merged 1 commit into
betafrom
fix/1547-anthropic-strict-schema

Conversation

@steilerDev
Copy link
Copy Markdown
Owner

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:

  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 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

  • `providerProfiles.test.ts` now asserts strict mode invariants
  • Server typecheck passes
  • No production code changed outside the schema constant

🤖 Generated with Claude Code

…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>
@steilerDev steilerDev merged commit a889cfe into beta May 23, 2026
61 of 64 checks passed
@steilerDev steilerDev deleted the fix/1547-anthropic-strict-schema branch May 23, 2026 16:09
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.7.0-beta.8 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant