Skip to content

[Bug] API returns 400 with MiMo models (Missing reasoning_content in multi-turn tool calls) #10544

Closed as not planned

Description

@jp689

Description

Describe the bug

When using MiMo reasoning models (e.g., MiMo-V2.5-Pro) in Agent mode with tool calls, the API throws a 400 Bad Request error on the second turn of the conversation.

Based on the official API documentation from the model provider, this happens because the reasoning_content generated in the first turn is not preserved and passed back in the subsequent request.

Steps to Reproduce

  1. Configure a MiMo reasoning model via the custom OpenAI/Anthropic API provider.
  2. Enable Agent mode / tool calls (e.g., asking it to search files or run a terminal command).
  3. Send a prompt that triggers a tool call. The first turn works fine.
  4. Send a follow-up prompt in the same conversation.
  5. The API immediately returns a 400 error.

Expected Behavior

The multi-turn conversation should continue smoothly with tool calling, and the model should receive the full context of its previous thoughts.

Root Cause Analysis

According to the provider's API guidelines:

If the model generates a reasoning_content field along with tool_calls in a turn, the client MUST include this exact reasoning_content field in the assistant message history for all subsequent API requests. If this field is missing when tool_calls exist in the history, the API will reject the request with a 400 error to prevent context fragmentation and hallucination.

It appears that Kilo Code currently strips out or drops the reasoning_content (or thinking blocks) from the assistant message history when building the messages array for the next round of requests.

Suggested Fix

When appending the assistant's previous response to the message history, please ensure that the reasoning_content field (if present) is mapped and fully preserved in the payload sent back to the API.

For example:

const assistantMsg: any = {
    role: "assistant",
    content: message.text,
    tool_calls: message.toolCalls
};
// Must preserve reasoning_content for API validation
if (message.reasoning_content) {
    assistantMsg.reasoning_content = message.reasoning_content;
}
messages.push(assistantMsg);

### Plugins

_No response_

### Kilo version

_No response_

### Steps to reproduce

_No response_

### Screenshot and/or share link

_No response_

### Operating System

_No response_

### Terminal

_No response_

Activity

  1. DavidMetcalfe commented on May 25, 2026

    @DavidMetcalfe

    Feels similar to the DeepSeek issues that were recently fixed.

    #9502

  2. bryan-emptycatch commented on Jun 7, 2026

    @bryan-emptycatch

    I'm experiencing this same bug repeatedly now. I'm using Deepseek V4 Flash (and it happens on Pro too).
    Mac Tahoe 26.5.
    Kilocode 7.3.40.
    SiliconFlow as a provider (openrouter is failing for me too)

    It definitely seems to coincide with a tool call. For this test I checked out: https://github.com/bryan-emptycatch/test-site. I gave it the following commands to try and tease it out:

    I want you to check out: https://github.com/bryan-emptycatch/test-site/
    Let's add a templating engine to this site.
    Let's add basic authentication to this site.
    Let's add SQLite as the database backend to the site.
    Let's add a basic users table we use to authenticate.

    There's no consistent way to produce it. It could have failed on any of those questions. I'd honestly just try repeating the flow a couple times to get it to fail.

    Image
  3. github-actions commented on Aug 7, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please reopen it or create a fresh new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions