You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.Net: [Python] KernelJsonSchemaBuilder maps None to JSON "object" in multi-member unions #14482
KernelJsonSchemaBuilder maps NoneType to JSON type "object" in multi-member unions. A type like int | str | None becomes anyOf: [integer, string, object] instead of including "null".
This breaks function-calling / agent tool schemas for pydantic model parameters: models may emit {} where null/omit was intended.
Distinct from open #14443 (Ge constraint objects in descriptions).
changed the title [-][Python] KernelJsonSchemaBuilder maps None to JSON "object" in multi-member unions[/-][+]Python: [Python] KernelJsonSchemaBuilder maps None to JSON "object" in multi-member unions[/+]on Sep 25, 2026
changed the title [-]Python: [Python] KernelJsonSchemaBuilder maps None to JSON "object" in multi-member unions[/-][+].Net: [Python] KernelJsonSchemaBuilder maps None to JSON "object" in multi-member unions[/+]on Sep 25, 2026
Hi uma-prasad (@michaelkillgta), thanks for the clear repro and root cause pointer — makes this easy to pick up.
I'd like to work on this if it's still available. From what I can see, TYPE_MAPPING in kernel_json_schema_builder.py doesn't have an entry for NoneType, so it falls back to "object" in get_json_schema. The handle_complex_type union handling also only special-cases the 2-arg Optional case, not unions with more than two members that include None.
My plan is to add a proper mapping for type(None) → {"type": "null"} and update the union handling so multi-member unions correctly include "null" instead of falling back to "object". I'll also add test cases covering both the direct KernelJsonSchemaBuilder.build() call and the function-calling format path you referenced.
Let me know if this approach sounds right, or if there's a preferred direction (e.g., always emitting anyOf with null vs. some other nullable representation).
Activity
[-][Python] KernelJsonSchemaBuilder maps None to JSON "object" in multi-member unions[/-][+]Python: [Python] KernelJsonSchemaBuilder maps None to JSON "object" in multi-member unions[/+][-]Python: [Python] KernelJsonSchemaBuilder maps None to JSON "object" in multi-member unions[/-][+].Net: [Python] KernelJsonSchemaBuilder maps None to JSON "object" in multi-member unions[/+]minahilatiqdev commentedon Sep 26, 2026
Hi uma-prasad (@michaelkillgta), thanks for the clear repro and root cause pointer — makes this easy to pick up.
I'd like to work on this if it's still available. From what I can see, TYPE_MAPPING in kernel_json_schema_builder.py doesn't have an entry for NoneType, so it falls back to "object" in get_json_schema. The handle_complex_type union handling also only special-cases the 2-arg Optional case, not unions with more than two members that include None.
My plan is to add a proper mapping for type(None) → {"type": "null"} and update the union handling so multi-member unions correctly include "null" instead of falling back to "object". I'll also add test cases covering both the direct KernelJsonSchemaBuilder.build() call and the function-calling format path you referenced.
Let me know if this approach sounds right, or if there's a preferred direction (e.g., always emitting anyOf with null vs. some other nullable representation).
aniketkrs commentedon Sep 27, 2026
Taking this on — opening a PR with the fix shortly.
michaelkillgta commentedon Sep 28, 2026
Thanks Minahil Atiq (@minahilatiqdev) and Aniket Kumar (@aniketkrs) — I see #14493 is open for this, so I'll leave it there and won't open a competing PR.