Repository navigation
Conversation
…esponse types _build_parameters fell back to _create_type_schema, which fell back to _build_parameters for every generic alias that is not list/dict/Union, so response_type=Literal[...], Set[int], Tuple[...] or frozenset[str] died with RecursionError while the tool schema was built. Treat other generics as their origin type.
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.
Problem
CreateChatCompletionbuilds the response schema with two mutually recursive helpers:_create_type_schema()only handleslist,dictandUnion; every other generic alias falls back to_build_parameters(), which falls back again - with no terminating branch. A perfectly normal structured-output type therefore crashes while the tool schema is built in__init__:Literalis a standard structured-output response type and nothing validates or rejects it (the constructor signature isresponse_type: Optional[Type] = str).Fix
For generics that are not list/dict/Union, build the schema from the origin type instead of recursing (
Literal[...]→ its value type,Set[int]/Tuple[...]→array), so every accepted annotation terminates.Tests
tests/tools(17 passed): parametrisedLiteral,Set,Tuple,frozensetall build a schema withresponserequired.