DeepSeek compatibility guide

Fix DeepSeek reasoning_content failures in tool-call loops.

Some OpenAI-compatible DeepSeek, MiMo and similar thinking-model routes work on the first request, then fail after a tool call because the adapter drops reasoning_content from conversation history.

Common error: the provider rejects the next request because the assistant message with tool_calls no longer includes the reasoning state that was streamed earlier.

1. Why this happens

OpenAI-compatible does not always mean OpenAI-identical. DeepSeek-style thinking models may stream reasoning in chunks before the final tool-call delta. If your framework only stores the final assistant message, the tool call is preserved but the reasoning text is lost.

Turn one works

The model streams reasoning and emits a tool call.

History is rebuilt

The adapter saves the tool call but drops provider reasoning state.

Turn two fails

The provider expects reasoning_content to be replayed with that assistant message.

2. Preserve reasoning on assistant tool-call messages

When the assistant emits tool calls, store any accumulated thinking content on the same assistant history item. For DeepSeek-compatible routes, replay it as reasoning_content on the next request.

{
  "role": "assistant",
  "content": "",
  "tool_calls": [
    {
      "id": "call_123",
      "type": "function",
      "function": {
        "name": "get_time",
        "arguments": "{\"city\":\"London\"}"
      }
    }
  ],
  "reasoning_content": "The user asked for the current time, so I need to call the time tool."
}

3. Test the second tool turn

A single tool call can hide the bug. Use a two-turn regression because the failure usually appears when the provider receives the next request.

  1. User asks for a tool call.
  2. Assistant streams reasoning chunks, then emits tool_calls.
  3. Tool returns.
  4. User asks a follow-up that forces another tool call.
  5. Assert that the previous assistant message still includes reasoning_content.

4. Keep provider-specific fields behind an adapter

Do not send reasoning_content to every OpenAI-compatible provider. Keep it behind provider capability checks so normal OpenAI routes stay clean, while DeepSeek/MiMo-compatible routes preserve the state they require.

5. When a hosted relay helps

If your app is failing against several Chinese model routes, isolate whether the bug is in the upstream provider, your framework adapter, or your local proxy. A small external OpenAI-compatible endpoint can help compare request and response behavior without changing the whole app.

Need a DeepSeek-compatible test route?

Black Eagle AI provides prepaid Chinese-model access for overseas developers. Start with one small request, then decide whether the route fits your agent or tool workflow.

Start $5 trial