kimi-code icon indicating copy to clipboard operation
kimi-code copied to clipboard

fix(kimi): add missing required arrays to tool schemas

Open cuipengcx90 opened this issue 4 months ago • 1 comments

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 required values, including invalid values that should remain visible to downstream validation.
  • Apply the same normalization in the Kosong and agent-core-v2 Kimi provider paths.
  • Cover root objects, nested properties, array items, allOf/anyOf/oneOf branches, existing and invalid required values, 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-v2 suite: 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-changesets skill, or this PR needs no changeset.
  • [x] Ran gen-docs skill, or this PR needs no doc update.

cuipengcx90 avatar Jul 21 '26 07:07 cuipengcx90

🦋 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

changeset-bot[bot] avatar Jul 21 '26 07:07 changeset-bot[bot]