fix(provider): ensure OpenAI tool schemas use array required#2085
fix(provider): ensure OpenAI tool schemas use array required#2085cuipengcx90 wants to merge 1 commit into
Conversation
OpenAI-compatible relays that forward to Moonshot backends validate tool parameters as Moonshot-flavored JSON Schema and reject non-array `required`. Normalize object schemas in toolToOpenAI so type=openai providers do not fail with "required must be an array".
🦋 Changeset detectedLatest commit: 420dc20 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: 420dc202fe
ℹ️ 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".
| }; | ||
| }; | ||
|
|
||
| /** |
There was a problem hiding this comment.
Move helper comments into the file header
In packages/agent-core-v2, the scoped convention allows comments only in the top-of-file /** */ header, so this new function-level JSDoc (and the helper JSDoc below it) makes the file violate the local comment rules. Please move the compatibility note into the module header or remove the inline blocks.
AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L13-L13
Useful? React with 👍 / 👎.
Summary
providers.*.type = "openai",toolToOpenAIpreviously passed toolparametersthrough unchanged.required, the upstream returns:toolToOpenAIforcerequired: []ontype: "object"nodes whenrequiredis missing or not an array (bothpackages/kosongandpackages/agent-core-v2).type = "kimi"path already runsnormalizeKimiToolSchema; this closes the gap for the OpenAI wire used by third-party relays.Test plan
pnpm --filter @moonshot-ai/kosong exec vitest run test/providers/openai-common-tool-schema.test.tskimiwithtype = "openai"against a Moonshot-strict relay, ensure tool-enabled turns no longer 400 onrequiredNotes
This is a focused wire-format compatibility fix. It does not change Anthropic/Google tool conversion.