Moonshot schema crashes on JSON Schema union types
Cluster 28291 · agent. Data as of
2 open items. Fix merged in #45579 on 13 Jun 2026. Check it covers your case.
The short answer
- Known?
- Yes. 12 related items grouped here, 3 issues already closed.
- Fix event
- A fix was merged to main in PR #45579. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
partially resolved, deciding PR #45579. That is separate from the fix event. - Still open
- 0 issues and 2 PRs.
Multiple bug reports and fix attempts addressing a TypeError caused by unhashable list values when Moonshot/Kimi tool schema sanitization encounters JSON Schema union type arrays. The fixes target two crash sites: _fill_missing_type and sanitize_moonshot_tools.
Open issues0
Open PRs2
Fixes on record
-
#45579 fix(moonshot): handle union type arrays in tool schemas
files:
agent/moonshot_schema.py,tests/agent/test_moonshot_schema.pyShow the diff
-
agent/moonshot_schema.py@@ -135,7 +135,14 @@ def _repair_schema(node: Any, is_schema: bool = True) -> Any: def _fill_missing_type(node: Dict[str, Any]) -> Dict[str, Any]: """Infer a reasonable ``type`` if this schema node has none.""" - if "type" in node and node["type"] not in {None, ""}: + node_type = node.get("type") + if isinstance(node_type, list): + concrete = next( + (t for t in node_type if isinstance(t, str) and t not in {"", "null"}), + "string", + ) + return {**node, "type": concrete} + if "type" in node and node_type not in {None, ""}: return node # Heuristic: presence of ``properties`` → object, ``items`` → array, ``enum`` -
tests/agent/test_moonshot_schema.py@@ -397,3 +397,52 @@ def test_anyof_collapse_still_runs_nullable_and_enum_cleanup(self): assert db_type["type"] == "string" assert db_type["enum"] == ["mysql", "postgresql"], \ "null/empty enum values must be stripped after anyOf collapse" + + +class TestUnionTypeList: + """Moonshot sanitizer accepts JSON Schema union type arrays.""" + + def test_union_type_list_normalizes_to_first_concrete_type(self): + params = { + "type": "object", + "properties": { + "limit": { + "type": ["number", "string"], + "description": "Max results", + }, + }, + } + + out = sanitize_moonshot_tool_parameters(params) + + assert out["properties"]["limit"]["type"] == "number" + + def test_union_type_list_skips_null_type(self): + params = { + "type": "object", + "properties": { + "name": {"type": ["null", "string"]}, + }, + } + + out = sanitize_moonshot_tool_parameters(params) + + assert out["properties"]["name"]["type"] == "string" + + def test_union_type_list_with_enum_does_not_crash_or_mutate_input(self): + params = { + "type": "object", + "properties": { + "sort": { + "type": ["string", "null"], + "enum": ["asc", "desc", None, ""], + }, + }, + } + + out = sanitize_moonshot_tool_parameters(params) + + sort = out["properties"]["sort"] + assert sort["type"] == "string" + assert sort["enum"] == ["asc", "desc"] + assert params["properties"]["sort"]["type"] == ["string", "null"]
-
6 PRs closed without merging
From the close comments: done elsewhere 3 · duplicate 1 · merged via another change 1 · superseded by another PR 1
-
#28422 fix: handle JSON Schema union type lists in moonshot_schema (both crash sites) · done elsewhere →
5acd185 -
#28772 fix(agent): accept union types in Moonshot schema sanitizer · done elsewhere →
5acd185 -
#28879 fix(moonshot): flatten union types before set check to avoid TypeError (#28787, #28291) · duplicate →
#28422,#28772,#28322 -
#29228 fix(moonshot): handle JSON Schema union types in _fill_missing_type (#28291) · superseded by another PR →
#28422 -
#30226 fix(moonshot): handle union type arrays in sanitize_moonshot_tools (#30095) · merged via another change →
5acd185,#45579
Show 1 more
-
#30753 fix(moonshot): normalise union type arrays in _fill_missing_type to prevent TypeError · done elsewhere →
5acd185
Closed issues · 3
- Closed#28291Bug: moonshot_schema._fill_missing_type crashes on JSON Schema union types (list type)
- Closed#28787TypeError: unhashable type: 'list' on kimi-k2.6:cloud via Ollama AND direct cloud — response parsing bug
- Closed#30095kimi-k2.6: TypeError: unhashable type 'list' in sanitize_moonshot_tools when tool has union type parameter
How this cluster was grouped
-
Link evidence (
partly structural links): some members are connected by structural evidence (shared changed files, or a closing/superseded reference); the rest are joined by an automated relevance judgement over their text. - Members outside that structural core may belong to a different underlying problem.
-
Pairwise link density
0.17: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the LabAt a glance
- Subsystem
- agent
- Merged PRs
- #45579
- Closed issues
- 3
- Attempts
- 6 PRs closed without merging
- Fix link checked
- 13 Jun 2026