LangChain drops reasoning content from CoT models: how to fix the LLM provider bug

Developers have found a serious bug in LangChain: ChatOpenAI, ChatDeepSeek, and other chat classes don't pass along the reasoning content block when integrating with LLM providers. While the model "thinks," the user stares at a blank screen. The author walked through the problem using stepfun/step-3.5-flash and polza.ai, and proposed a working fix that extends the standard classes.

AI-processed from Habr AI; edited by Hamidun News
LangChain drops reasoning content from CoT models: how to fix the LLM provider bug
Source: Habr AI. Collage: Hamidun News.
Listen to article

Developers using CoT models through LangChain have run into an unpleasant surprise: the framework's chat classes — ChatOpenAI, ChatDeepSeek, and similar ones — don't keep the reasoning content block in the final response. Users simply wait while the model "thinks" without getting any feedback, and the reasoning itself vanishes without a trace.

The problem affects integrations with most popular LLM providers and aggregators. When a reasoning model — say, one from the DeepSeek-R1 family or Stepfun's step-3.5-flash — generates a response, it records its internal reasoning in a separate reasoning_content block. That block is exactly what gets lost: neither ChatOpenAI nor LangChain's other chat classes pass it further down the processing chain.

Why does this matter? CoT (Chain of Thought) models are specifically trained to produce explicit reasoning steps before the final answer. Developers pick them for precisely that transparency: the ability to show users how the model reached its answer, or to feed intermediate steps into later stages of a pipeline. Lose the reasoning block, and the CoT approach loses its value.

The lack of reasoning content streaming hits UX directly. The user sees a blank screen while the model works through a reasoning chain several hundred tokens long. Perceived response time jumps sharply, even though the model is already working. For products where perceived speed is critical, that's a noticeable drawback.

The author ran into the problem in practice while using the stepfun/step-3.5-flash model through the Russian provider polza.ai. The provider sends reasoning content in the stream, but LangChain doesn't pick it up or pass it on. None of the aggregators tested solved the problem on their end.

The fix turned out to lie in extending LangChain's standard chat classes. The idea: override the method that processes streaming chunks so it explicitly extracts the reasoning_content field from the provider's response and adds it to the AIMessage output structure. That makes the reasoning block available both in streaming mode and in regular model calls.

In practice, this means creating a custom chat class that inherits from ChatOpenAI and overrides the _stream method along with the logic that assembles the final message. When streaming, reasoning_content starts appearing immediately, in step with the model generating its reasoning — which dramatically improves interface responsiveness.

The case matters not only as a technical fix but as a symptom of a broader problem: general-purpose frameworks like LangChain are slow to adapt to the specifics of new model classes. Providers use different API conventions for delivering reasoning content, and there's no unified approach — until one emerges, developers will have to close the gaps themselves through customization.

For teams building products on CoT models and LangChain, the approach described here offers a ready-made extension template. It works with any provider that returns reasoning_content in an OpenAI API-compatible format.

Story
ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
What do you think?
Loading comments…