@langchain/mistralai: reasoning models (zai-glm-5-3) crash on the second call: thinking chunks can't be sent back
Author: ratierdCreated Sep 28, 2026Updated Sep 28, 2026
Checked other resources
- This is a bug, not a usage question.
- I added a very descriptive title to this issue.
- I searched the LangChain.js documentation with the integrated search.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain.js rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
import { ChatMistralAI } from "@langchain/mistralai";
import { HumanMessage } from "@langchain/core/messages";
const model = new ChatMistralAI({ model: "zai-glm-5-3" });
const history = [new HumanMessage("What is 17 * 23?")];
const first = await model.invoke(history);
console.log(first.content.map((b) => b.type)); // ["thinking", ..., "text", ...]
history.push(first, new HumanMessage("Now divide it by 7."));
await model.invoke(history); // throwsError Message and Stack Trace (if applicable)
Error: Mistral only supports types "text" or "image_url" for complex message types.Description
Reasoning models served by Mistral (e.g. zai-glm-5-3) always return thinking content chunks before the answer. @langchain/mistralai puts them in the AIMessage content, but convertMessagesToMistralMessages throws when that same message is sent back.
So every multi-call flow fails on its second model call: a follow-up turn, or an agent loop after a tool call. The error is raised by the adapter before any request is sent; Mistral's API accepts thinking chunks on assistant messages. Reasoning can't be turned off for GLM 5.3 either: the API rejects reasoning_effort: "none".
Fixed by #11731.
Related: #11373 (separate GLM streaming bug, tool-call continuations with a "null" id).
System Info
@langchain/mistralai1.2.0- Node 24, macOS
Source: langchain-ai/langchainjs