fix(kimi): add missing required arrays to tool schemas#2001
Conversation
🦋 Changeset detectedLatest commit: 29164b0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29164b0f9e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return; | ||
| } | ||
|
|
||
| if (node['type'] === 'object' && !hasOwn(node, 'required')) { |
There was a problem hiding this comment.
Treat undefined required as missing
When a tool schema is built with an own required: undefined property (for example from a computed optional schema field), this guard treats it as present and skips adding []; the OpenAI client serializes JSON with undefined fields omitted, so the Kimi request still goes out without any required array and hits the same required must be an array rejection. The mirrored agent-core-v2 normalizer has the same guard, so both provider paths need to consider undefined missing while still preserving other invalid values if desired.
Useful? React with 👍 / 👎.
Related Issue
Related to #792 and #1610, but addresses a distinct schema-validation case.
PR #1720 sanitizes entries in an existing
requiredarray. This PR handles object schemas where therequiredproperty 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 withrequired must be an arraywhen a root or nested object node omits the property.Kimi Code already normalizes local references and missing
typefields for this provider, but it forwards missingrequiredproperties unchanged.What changed
required: []to explicitly typed or inferred object nodes only when the property is absent.requiredvalues, including invalid values that should remain visible to downstream validation.agent-core-v2Kimi provider paths.allOf/anyOf/oneOfbranches, existing and invalidrequiredvalues, non-object schemas, input immutability, and provider request conversion.@moonshot-ai/kimi-code.Validation
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.pnpm typecheck: passed.pnpm lint: exited successfully; changed files have zero warnings and zero errors under type-aware lint.git diff --check: passed.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.