Ensuring Robust AI Integrations: DeepSeek's `reasoning_content` and Copilot's Multi-Turn Challenge

In the rapidly evolving landscape of AI-powered developer tools, seamless integration between different services is paramount for maintaining developer productivity and ensuring the engineering quality software we build. A recent discussion on GitHub's community forums highlights a critical challenge faced by users integrating DeepSeek's 'thinking models' like deepseek-flash with GitHub Copilot.

A developer facing a screen, illustrating a broken API integration chain.
A developer facing a screen, illustrating a broken API integration chain.

The DeepSeek `reasoning_content` Conundrum

The core of the issue, reported by user jeremkief, revolves around a specific API requirement from DeepSeek when its models operate in 'thinking mode'. When a DeepSeek thinking model is used, particularly with tool calls, it returns a reasoning_content field within the assistant's message. Crucially, the DeepSeek API mandates that this reasoning_content must be echoed back verbatim in subsequent assistant messages within the same multi-turn conversation.

Copilot's Integration Gap

The problem arises because GitHub Copilot's provider adapter, specifically in version 1.0.87-0, appears to drop this vital reasoning_content field when persisting conversation history. Consequently, any follow-up request in a multi-turn conversation, after thinking mode has been triggered, fails with an HTTP 400 error:

400 The `reasoning_content` in the thinking mode must be passed back to the API.

This omission effectively breaks the conversation flow, preventing developers from continuing their work with the AI assistant. The bug is more easily triggered by agent flows that involve several internal or tool-related requests within a single turn, emphasizing the need for robust API handling in complex scenarios to ensure engineering quality software.

Steps to Reproduce

Users can reproduce this behavior by:

  1. Configuring Copilot to use the DeepSeek API with deepseek-flash (e.g., setting COPILOT_PROVIDER_BASE_URL=https://api.deepseek.com, COPILOT_PROVIDER_TYPE=openai, COPILOT_MODEL=deepseek-flash).
  2. Enabling thinking/reasoning mode.
  3. Starting a conversation and sending a prompt that activates thinking mode.
  4. Continuing the same conversation with a follow-up message.

The expected behavior is for Copilot to preserve and include the reasoning_content. However, the actual behavior is its omission, leading to the API rejection.

Towards a Solution for Enhanced API Compatibility

This isn't an isolated incident; similar issues have been noted in related discussions, including a previously closed issue (#2995) concerning DeepSeek and OpenAI-compatible providers, and another affecting VS Code Copilot Chat with OpenRouter's DeepSeek models (#193953). This recurrence underscores a broader challenge in maintaining compatibility across diverse AI APIs and their specific requirements.

The suggested fix involves a fundamental improvement in how Copilot handles conversation history: preserving extra or unknown fields on assistant messages when persisting them. By ensuring that fields like reasoning_content are not inadvertently dropped, Copilot can meet DeepSeek's API contract, enabling uninterrupted multi-turn conversations. Implementing such a solution is crucial for enhancing the reliability of developer tools and contributing to the overall engineering quality software ecosystem.

This incident serves as a vital reminder for developers and tool builders about the intricacies of API integration. As AI models become more sophisticated with features like 'thinking mode' and tool calling, the responsibility to meticulously handle all aspects of their API contracts falls on the integrating platforms. Ensuring such details are correctly managed is key to delivering truly productive and dependable AI assistance.

Interlocking gears representing Copilot and DeepSeek API, with one gear having a missing tooth, symbolizing an integration failure.
Interlocking gears representing Copilot and DeepSeek API, with one gear having a missing tooth, symbolizing an integration failure.

|

Dashboards, alerts, and review-ready summaries built on your GitHub activity.

 Install GitHub App to Start
Dashboard with engineering activity trends