Repository navigation
utils: serialize union tool parameter types as a JSON Schema type array - #785
Open
AP24110011695 wants to merge 1 commit into
Open
AP24110011695 wants to merge 1 commit into
AP24110011695 wants to merge 1 commit into
Conversation
convert_function_to_tool joined a parameter's multiple types with
commas ('string, integer'), which is not a valid JSON Schema type and
nondeterministic (set iteration order). Property.type already accepts a
sequence of strings, so emit a sorted type array for unions and keep
the scalar string for single types.
Author
|
Also updated the pre-existing union assertion in |
AP24110011695
force-pushed
the
fix/tool-union-type-schema
branch
from
November 1, 2026 12:06
2de2356 to
5fbb8f3
Compare
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.
Problem
convert_function_to_toolbuilds each property'stypeby joining the parameter's types with commas:currently produces:
{"type": "string, integer"}"string, integer"is not a valid JSON Schematype(it must be a single string or an array of strings), so models receive a schema no validator accepts. The value is also nondeterministic - the types come from a set, so the join order varies per run.Fix
Tool.Function.Parameters.Property.typeis already typedUnion[str, Sequence[str]], so unions are emitted as a sortedtypearray (["integer", "string"]); single types (including Optional after the null is discarded) stay scalar strings. The sorting makes output deterministic.Tests
test_convert_function_to_tool_union_typesfails onmain(35d9667) and passes with this change;test_convert_function_to_tool_optional_type_stays_scalarpins the existing Optional behavior.