Claude Messages API 推出 message threads(beta):服务器暂存对话,每轮只发新消息

Claude 平台更新日志 11 月 2 日:Messages API 新增 message threads(消息线程),以 beta 形式提供,需要带 message-threads-2026-08-12 beta 头。第一次请求照常发送完整对话、system 和 tools,并加上 "thread": {"type": "create"};之后每轮只发新消息和上一条回复的 id("type": "continue"),由服务器拼回完整对话再调用模型。线程在最后一次请求后 5 分钟过期,最迟 1 小时内删除。Claude API、Claude Platform on AWS、Claude Models on Google Cloud(Anthropic 托管)和 Microsoft Foundry 上的 Claude 都可用。

Claude 平台更新日志 11 月 2 日:Messages API 新增 message threads(消息线程),以 beta 形式提供,需要带 message-threads-2026-08-12 beta 头。第一次请求照常发送完整对话、system 和 tools,并加上 "thread": {"type": "create"};之后每轮只发新消息和上一条回复的 id("type": "continue"),由服务器拼回完整对话再调用模型。线程在最后一次请求后 5 分钟过期,最迟 1 小时内删除。Claude API、Claude Platform on AWS、Claude Models on Google Cloud(Anthropic 托管)和 Microsoft Foundry 上的 Claude 都可用。

置信度:高(80) · 事件时间 2026-11-02

理由

  • 不用线程时,每一轮都要把整段对话重新上传,API 也要重新校验和分词;对动辄几十上百轮工具调用的智能体循环,请求体越来越大、首字延迟越来越高。官方文档称有了线程,大部分工作只针对新增的一轮,首字延迟会更低、更稳定。
  • 它不替代提示缓存:缓存断点照样由开发者自己设,可以用顶层 cache_control 让每轮自动缓存;两者配合才能同时省延迟和省钱。

用法

  • 请求头加 anthropic-beta: message-threads-2026-08-12;第一轮加 thread: {type: "create"},之后用 thread: {type: "continue", previous_message_id: <上一条回复 id>},只发新消息,不再发 system 和 tools(再发会报 400)。官方 SDK 有 thread 辅助对象,会自动处理 beta 头和 404 后的重放。文档见 platform.claude.com/docs 的 “Message threads” 页面。

风险

  • 线程是“尽力而为”:过期、由后备模型生成的回复、换了用户或工作区等情况下,continue 请求会返回 404,必须用完整对话重新 create,所以应用仍要自己保存全部消息并预先写好重放逻辑。
  • model、thinking、tool_choice 等字段在整个线程内必须保持不变,改动会报 thread_fingerprint_mismatch;在 Opus 5.5 等模型上改 system 或 tools 会让已有的 thinking 块失效。beta 阶段行为可能变化。

打开 · Claude 文档:Message threads

Claude 平台更新日志

浏览最新 AI 动态