diff --git a/packages/kosong/src/providers/kimi-schema.ts b/packages/kosong/src/providers/kimi-schema.ts index 93b428c642..913e113257 100644 --- a/packages/kosong/src/providers/kimi-schema.ts +++ b/packages/kosong/src/providers/kimi-schema.ts @@ -116,8 +116,9 @@ const NUMERIC_STRUCTURE_KEYS = new Set([ * a provider-compatibility normalizer, not a complete JSON Schema compiler: * it resolves local refs, preserves combinator nodes, infers obvious * scalar/object/array types, and falls back to `string` only for nested - * typeless property schemas. The root schema object is treated as a container - * and is not itself normalized. + * typeless property schemas. It also rewrites nodes that declare `type` + * alongside a combinator (`anyOf` / `oneOf` / `allOf`), which Moonshot + * rejects, by moving the parent `type` into each combinator item. */ export function normalizeKimiToolSchema(schema: Record): Record { return ensureKimiPropertyTypes(derefJsonSchema(schema)); @@ -128,10 +129,36 @@ function ensureKimiPropertyTypes(schema: Record): Record hasUnresolvedDefinitionRef(child, bucketKey)); @@ -300,6 +327,8 @@ function normalizeProperty(node: unknown): void { return; } + fixCombinatorParentType(node); + if (!hasOwn(node, 'type') && !hasAnyKey(node, TYPE_COMPLETION_SKIP_KEYS)) { const enumValues = node['enum']; if (Array.isArray(enumValues) && enumValues.length > 0) {