fix(kimi): add missing required arrays to tool schemas
Related Issue
Related to #792 and #1610, but addresses a distinct schema-validation case.
PR #1720 sanitizes entries in an existing required array. This PR handles object schemas where the required property is absent.
Problem
Standard JSON Schema permits object schemas to omit required. Kimi-compatible APIs apply stricter Moonshot-flavored JSON Schema validation and may reject tool definitions before execution with required must be an array when a root or nested object node omits the property.
Kimi Code already normalizes local references and missing type fields for this provider, but it forwards missing required properties unchanged.
What changed
- Add
required: []to explicitly typed or inferred object nodes only when the property is absent. - Preserve existing
requiredvalues, including invalid values that should remain visible to downstream validation. - Apply the same normalization in the Kosong and
agent-core-v2Kimi provider paths. - Cover root objects, nested properties, array items,
allOf/anyOf/oneOfbranches, existing and invalidrequiredvalues, non-object schemas, input immutability, and provider request conversion. - Add a patch changeset for
@moonshot-ai/kimi-code.
Validation
- Kosong suite: 1,283 tests passed.
- Kimi-focused suites: 147 tests passed.
agent-core-v2suite: 3,694 tests passed; one unrelated timing-sensitive plan event snapshot failed in the full parallel run and passed when rerun in isolation.- Root
pnpm typecheck: passed. - Root
pnpm lint: exited successfully; changed files have zero warnings and zero errors under type-aware lint. git diff --check: passed.
Checklist
- [x] I have read the CONTRIBUTING document.
- [x] I have linked a related issue, or explained the problem above.
- [x] I have added tests that prove my feature works.
- [x] Ran
gen-changesetsskill, or this PR needs no changeset. - [x] Ran
gen-docsskill, or this PR needs no doc update.
🦋 Changeset detected
Latest commit: 29164b0f9e7375b1e6e51dd83534a087ad945efe
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @moonshot-ai/kimi-code | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR