Repository navigation
Conversation
…cription `const` is a supported keyword for structured outputs, and pydantic emits it for every single-value `Literal`, including the tag field of a discriminated union. transform_schema() did not handle it, so it fell through to the unsupported-keyword fallback and reached the API as description text.
This branch has not been deployed
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.
This carries @pravinireri's #1860 forward against
main. It's the same fix. #1860 targetednext, and it closed unreviewed on 2026-10-08 with the other opennextpull requests.transform_schema()has no case forconst, so it falls through to the unsupported-keyword fallback insrc/anthropic/lib/_parse/_transform.py. It reaches the API as text indescription. The structured outputs docs listconstas supported. Pydantic emits it for every single-valueLiteral, including the tag of a discriminated union, somessages.parse()sends that tag as a free string.Before, on
b4b7916, forPetwithpet: Union[Cat, Dog] = Field(discriminator="kind")andkind: Literal["cat"]/Literal["dog"]:After:
constnow sits besideenum, which the function already passes through since #1275. It checks for the key, soconst: nullsurvives too. No issue exists. Refs #1860.Verification
Reverting
_transform.pyand keeping the tests gives2 failed, 14 passed:test_const_schemaandtest_const_from_pydantic_literal_discriminator.@meorphis-anthropic, was the close of #1860 about the
nextbranch or about the change? @craigie-ant, this and my #2015 are both smalltransform_schemafixes, and I can fold them into one pull request if that's easier to review.