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

fix(provider): ensure OpenAI tool schemas use array required

Open cuipengcx90 opened this issue 4 months ago • 1 comments

Summary

  • OpenAI-compatible relays that forward to Moonshot backends validate tool parameters as Moonshot-flavored JSON Schema.
  • With providers.*.type = "openai", toolToOpenAI previously passed tool parameters through unchanged.
  • If any object schema had missing / non-array required, the upstream returns:
400 Invalid request: ***.***.parameters is not a valid moonshot flavored json schema
details: <At path 'required': required must be an array>
  • This PR makes toolToOpenAI force required: [] on type: "object" nodes when required is missing or not an array (both packages/kosong and packages/agent-core-v2).
  • The type = "kimi" path already runs normalizeKimiToolSchema; this closes the gap for the OpenAI wire used by third-party relays.

Test plan

  • [x] pnpm --filter @moonshot-ai/kosong exec vitest run test/providers/openai-common-tool-schema.test.ts
  • [ ] CI full suite on this PR
  • [ ] Manual: kimi with type = "openai" against a Moonshot-strict relay, ensure tool-enabled turns no longer 400 on required

Notes

This is a focused wire-format compatibility fix. It does not change Anthropic/Google tool conversion.

cuipengcx90 avatar Jul 23 '26 02:07 cuipengcx90

🦋 Changeset detected

Latest commit: 420dc202fe5e017070308680f46a319c0025616f

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 23 '26 02:07 changeset-bot[bot]