> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MESSAGE_COERCION_FAILURE

当消息对象不符合预期格式时，会发生此错误。

待办：添加 JS 示例

## 故障排除

要解决此错误：

1. **确保格式正确**：所有输入到聊天模型的内容必须是 LangChain 消息类的数组或支持的类消息格式
2. 验证您的消息没有发生意外的字符串化或转换
3. 检查错误的堆栈跟踪，并添加日志语句以检查传递给模型之前的消息对象

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs)通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/langchain/errors/MESSAGE_COERCION_FAILURE.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
