fix(moonshot): handle union type arrays in sanitize_moonshot_tools (#30095)#30226
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
fix(moonshot): handle union type arrays in sanitize_moonshot_tools (#30095)#30226Tranquil-Flow wants to merge 1 commit into
Tranquil-Flow wants to merge 1 commit into
Conversation
Collaborator
Contributor
Author
|
Thanks for the heads-up @alt-glitch — I've reviewed #28422 and #28322 and updated this branch. How this PR differs from #28422Both #28322 and #28422 preserve union type lists as-is (pass-through). This PR takes a different approach: it normalises the union type to the first concrete scalar. Why normalisation matters: Moonshot's API rejects union type arrays ( What changed (commit
|
| #28322 | #28422 | This PR | |
|---|---|---|---|
_fill_missing_type site |
✅ | ✅ | ✅ (normalise, not just preserve) |
_repair_schema site |
✅ | ✅ | ✅ (defensive guard) |
| Approach | Preserve list | Preserve list | Normalise to first concrete |
| Tests | 1 | 4 | 10 |
This PR now covers both crash sites with the more semantically correct approach.
This was referenced May 23, 2026
3eaa5da to
84c2e17
Compare
Contributor
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.
Summary
Fixes #30095: Kimi K2.6 crashes with
TypeError: unhashable type 'list'when a tool has a parameter with union type (e.g.,{"type": ["string", "null"]}).Root Cause
In
sanitize_moonshot_tools(),_fill_missing_typeiterated over each parameter dict looking foranyOf/oneOf/etc., but when the type field is a list (JSON Schema union syntax), the function treats each element of the list as a dict and crashes trying to call.get()on a string.Fix
Early-return in
_fill_missing_typewhenparam_valueis not a dict, so union-type arrays and other non-dict parameter values are passed through without attempting property fill.Changes
Closes #30095