Repository navigation
Description
Summary
When using Kimi Code through an OpenAI-compatible provider in OpenClaw, a normal single-turn response can succeed, but enabling thinking for an agent turn that uses tools fails during tool-call replay.
The provider rejects the follow-up request with:
400 thinking is enabled but reasoning_content is missing in assistant tool call message at index 2
This looks like the OpenAI-compatible replay path is not preserving or reconstructing the assistant reasoning_content required by Kimi Code when thinking is enabled and tool calls are replayed.
Environment
- OpenClaw version:
2026.6.1 - Gateway version:
2026.6.1 - Provider id:
moonshot-code - Model id:
kimi-for-coding - API style:
openai-completions - Base URL:
https://api.kimi.com/coding/v1 - Current workaround: keep Kimi Code thinking disabled and use it as a late fallback.
Current working model config workaround:
{
"id": "kimi-for-coding",
"name": "Kimi Code (for coding)",
"api": "openai-completions",
"reasoning": false,
"compat": {
"supportsReasoningEffort": false,
"maxTokensField": "max_tokens"
}
}Agent model params workaround:
{
"max_tokens": 65536,
"thinking": false
}Reproduction
- Configure Kimi Code as an OpenAI-compatible provider with reasoning enabled:
{
"models": {
"providers": {
"moonshot-code": {
"baseUrl": "https://api.kimi.com/coding/v1",
"apiKey": "${KIMI_API_KEY}",
"api": "openai-completions",
"models": [
{
"id": "kimi-for-coding",
"name": "Kimi Code (for coding)",
"input": ["text", "image"],
"reasoning": true,
"contextWindow": 131072,
"maxTokens": 65536,
"compat": {
"supportsReasoningEffort": true,
"maxTokensField": "max_tokens"
},
"api": "openai-completions"
}
]
}
}
}
}- Run a simple thinking-enabled turn:
openclaw agent \
--model moonshot-code/kimi-for-coding \
--thinking high \
--session-key agent:codex:kimi-thinking-simple \
--message 'Test Kimi Code thinking high. Reply only KIMI_THINK_SIMPLE_OK_9.' \
--jsonThis succeeds.
- Run a thinking-enabled tool turn:
openclaw agent \
--model moonshot-code/kimi-for-coding \
--thinking high \
--session-key agent:codex:kimi-thinking-tool \
--message 'You must call exec to run: printf KIMI_TOOL_OK. Then reply only FINAL_KIMI_TOOL_OK.' \
--jsonActual result
The run fails with:
GatewayClientRequestError: FailoverError: LLM request failed: provider rejected the request schema or tool payload.
Gateway logs show the provider error:
400 thinking is enabled but reasoning_content is missing in assistant tool call message at index 2
Relevant diagnostic fields:
{
"provider": "moonshot-code",
"model": "kimi-for-coding",
"failoverReason": "format",
"providerRuntimeFailureKind": "schema",
"rawErrorPreview": "400 thinking is enabled but reasoning_content is missing in assistant tool call message at index 2"
}Expected result
OpenClaw should either:
- Preserve and replay Kimi Code
reasoning_contentcorrectly for assistant messages that contain tool calls, or - Automatically disable thinking for Kimi Code tool-using sessions when the provider requires
reasoning_contentreplay that OpenClaw cannot satisfy, or - Expose a provider compat flag similar to existing reasoning replay controls so Kimi Code can be configured safely.
Workaround
Keep Kimi Code configured with thinking disabled and use it only as a fallback:
{
"reasoning": false,
"compat": {
"supportsReasoningEffort": false,
"maxTokensField": "max_tokens"
}
}Agent params:
{
"max_tokens": 65536,
"thinking": false
}This avoids the replay failure, but prevents thinking-enabled Kimi Code tool use.
Additional notes
I tested Qwen3.7 Plus with OpenClaw compat.thinkingFormat: "qwen" under the same style of tool-call replay test. Qwen completed the tool turn and a follow-up turn successfully. So this appears to be specific to Kimi Code / Moonshot-style reasoning_content replay behavior rather than all OpenAI-compatible thinking providers.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 9, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Current main already has the safe Kimi Code replay path: the OpenAI-compatible transport now honors the explicit reasoning-content compat flag for custom providers, and the bundled Kimi provider backfills
reasoning_contenton assistant tool-call replay when thinking is enabled. This is current-main-only for the custom-provider fix, so the reported v2026.6.1 behavior is explained by the release lag.So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the current-main compat behavior and direct custom Kimi OpenAI-compatible users to either the bundled
kimi/kimi-for-codingprovider orcompat.requiresReasoningContentOnAssistantMessages: trueuntil the next release ships it.Do we have a high-confidence way to reproduce the issue?
Yes for the shipped failure path at source level: v2026.6.1 ignored the explicit custom-provider compat flag in the agent transport, while current main honors it. I did not run the live Kimi request without credentials.
Is this the best way to solve the issue?
Yes. The maintainable fix is to keep Kimi-specific behavior in the bundled provider and expose the generic compat flag for custom OpenAI-compatible routes instead of hard-coding every custom provider id.
Security review:
Security review: No patch is under review, and the issue does not report a security-sensitive behavior.
AGENTS.md: found and applied where relevant.
What I checked:
AGENTS.md:1, aa935ddeb23f)compat.requiresReasoningContentOnAssistantMessagesfrom the configured model before building OpenAI-compatible replay payloads, so custom Kimi-style providers can opt into the required replay contract. (src/agents/openai-transport-stream.ts:3440, 55de547b5214)reasoning_contentare backfilled with an empty string before the request is sent. (src/llm/providers/openai-completions.ts:1062, 55de547b5214)requiresReasoningContentOnAssistantMessages, matching the safe configuration requested by the issue. (src/agents/openai-transport-stream.test.ts:10123, 55de547b5214)reasoning_content: ""to assistant messages with OpenAI tool calls when thinking is enabled, preserving native reasoning when already present. (extensions/kimi-coding/stream.ts:90, 55de547b5214)models.providers.*.models.*.compat.requiresReasoningContentOnAssistantMessagesand the built-inkimi/kimi-for-codingprovider path. Public docs:docs/gateway/config-tools.md. (docs/gateway/config-tools.md:572, aa935ddeb23f)Likely related people:
src/agents/openai-transport-stream.ts,extensions/kimi-coding/stream.ts,docs/providers/moonshot.md)extensions/kimi-coding/stream.ts)kimi/kimi-for-coding. (role: feature-history contributor; confidence: medium; commits: bf15d0a3f5e1; files:docs/providers/moonshot.md,extensions/kimi-coding/index.ts)Codex review notes: model gpt-5.5, reasoning high; reviewed against aa935ddeb23f; fix evidence: commit 55de547b5214, main fix timestamp 2026-06-09T01:02:22+02:00.