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
The v0.8.61 fix for #3265 (sanitize_for_kimi_parameters) only adds "type": "object" to the parameters root when the schema matches a narrow set of conditions:
let root_object_schema = obj.is_empty()
|| obj.contains_key("properties")
|| obj.contains_key("required")
|| obj.contains_key("additionalProperties");
This means other valid JSON Schema root shapes are left without type — and Kimi/Moonshot still rejects them with the same 400 error:
{"$ref": "#/definitions/FileArgs"} — no type added
{"allOf": [...]} — no type added
{"anyOf": [...]} — no type added
{"oneOf": [...]} — no type added
Secondary issue: sanitize_for_kimi removes type from root
Even for schemas that DO get type: "object" injected, the subsequent sanitize_for_kimi pass removes type from the parent when anyOf/oneOf is present:
// sanitize_for_kimi, line 979-981:let should_push = obj.contains_key("type")
&& (obj.contains_key("anyOf") || obj.contains_key("oneOf"));if should_push && letSome(type_val) = obj.remove("type"){// pushes type into items, removes from parent}
After sanitize_for_kimi_parameters adds type → then sanitize_for_kimiremoves it. Net result: no type at root → Kimi 400.
Reproduction
Same as #3265 — switch to Moonshot provider with kimi-k2.7-code, send any message. The error persists in v0.8.61 for tools whose parameters use $ref / anyOf / allOf / oneOf at root.
Suggested Fix
sanitize_for_kimi_parameters: always add "type": "object" when missing, not just for the narrow root_object_schema shapes
Description
The v0.8.61 fix for #3265 (
sanitize_for_kimi_parameters) only adds"type": "object"to the parameters root when the schema matches a narrow set of conditions:This means other valid JSON Schema root shapes are left without
type— and Kimi/Moonshot still rejects them with the same 400 error:{"$ref": "#/definitions/FileArgs"}— notypeadded{"allOf": [...]}— notypeadded{"anyOf": [...]}— notypeadded{"oneOf": [...]}— notypeaddedSecondary issue:
sanitize_for_kimiremovestypefrom rootEven for schemas that DO get
type: "object"injected, the subsequentsanitize_for_kimipass removestypefrom the parent whenanyOf/oneOfis present:This means a parameters schema like:
{"anyOf": [{"type": "object", "properties": {...}}, {"type": "null"}]}After
sanitize_for_kimi_parametersaddstype→ thensanitize_for_kimiremoves it. Net result: notypeat root → Kimi 400.Reproduction
Same as #3265 — switch to Moonshot provider with kimi-k2.7-code, send any message. The error persists in v0.8.61 for tools whose parameters use
$ref/anyOf/allOf/oneOfat root.Suggested Fix
sanitize_for_kimi_parameters: always add"type": "object"when missing, not just for the narrowroot_object_schemashapessanitize_for_kimi: when pushingtypeintoanyOf/oneOfitems, keep it on the parent instead of removing it — Kimi requirestypeat every level ([moonshot] tools.function.parameters.type is required and must be "object" — empty {} rejected by Kimi API #3265)Environment
openai_compatible