Repository navigation
fix(adapter): ensure root object type for Kimi tool schemas - #250
Merged
Merged
Conversation
Kimi requires function.parameters.type to be exactly 'object' at the root. Codex tools with oneOf/anyOf schemas (like automation_update) omit the root type, causing 400 errors: 'tools.function.parameters.type is required and must be object'. Add provider-scoped normalization for api.kimi.com that ensures type: 'object' at the root while preserving oneOf, \, descriptions, and other schema keys. Similar to the existing xAI and Zen schema handling. Fixes #228
2 tasks done
agentHits
pushed a commit
to agentHits/opencodex
that referenced
this pull request
Sep 17, 2026
…n#250) fix(adapter): ensure root object type for Kimi tool schemas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Issue #228: Kimi returns HTTP 400 when a Codex tool schema has no root
type: "object". The error istools.function.parameters.type is required and must be "object".Codex tools like
automation_updateuse valid JSON Schema with a rootoneOfand no explicit roottype. OpenCodex forwards that schema unchanged to Kimi's OpenAI-compatible function format. Kimi requiresfunction.parameters.typeto be exactly"object", so it rejects the complete request before the model can call the tool.Root cause
In
src/adapters/openai-chat.ts,toolsToChatFormat()passest.parametersthrough unchanged for Kimi. There are already provider-specific schema paths for xAI and Zen, but Kimi currently uses the unmodified path.Fix
Add provider-scoped normalization for
api.kimi.comthat ensurestype: "object"at the root while preservingoneOf,$defs, descriptions, and other schema keys. Similar to the existing xAI and Zen schema handling.Verification
bun x tsc --noEmitpassessrc/adapters/openai-chat.tsautomation_updateschema