Repository navigation
Description
[Bug] OpenCode Go: Kimi K2.6 rejects tool schemas with if/then/else conditionals
Description
OpenCode Go does not transform tool schemas for Moonshot AI models (kimi-k2.6, kimi-k2.5), causing 400 Bad Request errors when any client sends standard OpenAI-compatible tool definitions that contain conditional schemas.
The error occurs at the Moonshot API validation layer before the request reaches the model.
Environment
- Provider: OpenCode Go (
https://opencode.ai/zen/go/v1) - Model:
kimi-k2.6(alsokimi-k2.5) - Client: pi (earendil-works/pi) v0.79.1 via litellm 1.85.0
- API mode:
chat_completions
Error Message
400 litellm.BadRequestError: OpenAIException - Error from provider:
Conflict in schema definitions for key 'if'.
Previous: {'required': ['expand']}, New: {'required': ['collect']}
The error is wrapped by the Vercel AI SDK as AI_APICallError: Error from provider: Provider returned error in some clients (see #23665).
Root Cause
Moonshot AI's JSON Schema validator is stricter than standard OpenAI:
- It does not accept
if/then/elseconditional schemas in tool definitions - It does not accept
descriptionafter$refexpansion - It does not accept
properties.variantOptionspatterns - It expects a "moonshot flavored JSON schema" (quoted from their error messages)
Comparison with Other Models (Same Provider)
| Model | OpenCode Go | Tool Schemas | Status |
|---|---|---|---|
deepseek-v4-pro |
✅ | ✅ | Works perfectly |
glm-5.1 |
✅ | ✅ | Works perfectly |
qwen3.5-plus |
✅ | ✅ | Works perfectly |
minimax-m2.5 |
✅ | ✅ | Works perfectly |
kimi-k2.6 |
✅ | ❌ | Fails with 400 |
kimi-k2.5 |
✅ | ❌ | Fails with 400 |
Expected Behavior
OpenCode Go should transform or sanitize tool schemas for Kimi models before forwarding to Moonshot AI, similar to how it handles thinking/reasoning mode conversions (see #5169 fix).
Suggested Fix
-
Provider-side schema normalization: When
modelstarts withkimi-*, transform the incoming OpenAI tool schemas to Moonshot-compatible format:- Remove
if/then/elseblocks (flatten toanyOf/oneOfif possible) - Remove
descriptionafter$ref - Strip
variantOptionspatterns - Simplify nested
requiredarrays
- Remove
-
Or: Document the limitation and provide a client-side workaround option
Related Issues
- [Bug]: OpenCode Go + Kimi K2.6/K2.5 returns 'Provider returned error' on CLI 1.14.20 #23887 — "OpenCode Go + Kimi K2.6/K2.5 returns 'Provider returned error'"
- The provider error is caused by tool schema incompatibility, not by prompt failure. #24158 — "tool schema incompatibility with Moonshot AI"
- KIMI K2.6 showing error in Opencode GO #27054 — "KIMI K2.6 showing error in Opencode GO"
- "Provider returned error" hides actual Kimi/Moonshot API errors | Opencode GO | kimi k2.6 #23665 — "Provider returned error hides actual Kimi/Moonshot API error details"
- earendil-works/pi Feat/revolutionary ai enhancements #5169 — Previous kimi-k2.6 thinking-mode issue (fixed in pi v0.78.0)
Additional Context
- This is not the same as the previous thinking-mode issue. That was fixed by pi (client side). This requires server-side schema transformation.
- litellm's
drop_params: truedoes not help because the issue is in the JSON Schema structure, not in parameters. - The error is deterministic — it happens on every tool request with kimi-k2.6/k2.5.
Activity
github-actions commentedon Jun 10, 2026
This issue might be a duplicate of existing issues. Please check:
If your issue is specifically about
if/then/elseconditional schemas being rejected and not covered by the above, feel free to clarify how it differs so it can be tracked separately.github-actions commentedon Aug 9, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.