Repository navigation
support default arguments on function tools - #2076
Merged
Merged
Conversation
Contributor
|
blakemjones
reviewed
May 1, 2025
| if json_schema.get("default", NOT_GIVEN) is None: | ||
| json_schema.pop("default") | ||
| # strict mode doesn't support default | ||
| if json_schema.get("default") is not None: |
There was a problem hiding this comment.
This needs to be if "default" in json_schema.
A standard default value is None, so if a user wants to specify a default value as None this won't catch it.
u9g
added a commit
that referenced
this pull request
Aug 3, 2026
…inator The guard fired on a keyword the API does not object to: a live strict tool call is accepted with `discriminator` present, and only `oneOf` is rejected — which _ensure_strict_json_schema already converts. So the guard rejected schemas that work, and refusing them broke discriminated unions that used to build fine. The `discriminator` pop it replaced had no stated purpose either (added in #2076 alongside pop("title"), not inherited from openai-python, and unreachable for discriminated unions until #5324 converted oneOf), and nothing reads the keyword back — pydantic re-derives the tag from the model. Leave it in the schema. The fidelity problem the guard was aimed at is the null sentinel landing on a defaulted tag field, fixed separately against main.
u9g
added a commit
that referenced
this pull request
Aug 6, 2026
…inator The guard fired on a keyword the API does not object to: a live strict tool call is accepted with `discriminator` present, and only `oneOf` is rejected — which _ensure_strict_json_schema already converts. So the guard rejected schemas that work, and refusing them broke discriminated unions that used to build fine. The `discriminator` pop it replaced had no stated purpose either (added in #2076 alongside pop("title"), not inherited from openai-python, and unreachable for discriminated unions until #5324 converted oneOf), and nothing reads the keyword back — pydantic re-derives the tag from the model. Leave it in the schema. The fidelity problem the guard was aimed at is the null sentinel landing on a defaulted tag field, fixed separately against main.
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.
fix #1987
Note that the LLM isn't aware of the default value, this context isn't added, it isn't supported by strict function descriptions.
Users need to add it on their function tool description if necessary