多轮会话在只聊天时看不出问题。工具加入后,有的网关或 SDK 为了展示清晰会丢掉推理字段,序列化回放突然变成 400。输入历史和展示日志应该是分离的。
操作步骤
- 先记录模型 ID、接口格式、thinking 与 tools 开关,按当前官方 DeepSeek Chat Completions 文档复核。纯文本回放保留历史 content 和消息顺序。
- 若下一请求携带 tools,按协议完整保留此前 assistant 的 reasoning_content,即使其中某轮未实际调用工具;同时保留 tool_calls 与对应的 tool_call_id。
- 检查持久层与适配器有无删字段或改名,对照纯文本与带工具两份最小用例。仅在授权会话内保存需要回放的数据,日志仍使用脱敏字段名和长度。
文档字段对照
两组回放序列(字段核对)
plain request: user → assistant(content) → user
tool request: assistant(content, reasoning_content, tool_calls)
→ tool(tool_call_id, content) → assistant(content, reasoning_content)
expected: preserved fields; missing required reasoning_content can produce HTTP 400如果同一历史在纯文本通过、带工具时 400,先比模型和请求结构,定位是字段缺失还是 tool_call_id 对不上。
若计划跨组切换 DeepSeek,先核对准确型号、接口和实际渠道价格。可查看 DeepSeek 型号与参考价,按量付费,无需月费。
适用范围
本文按当前 Chat Completions thinking 协议。旧版 Reasoner、Anthropic 兼容端点与其他 DeepSeek 路由的回放规则需按各自文档验证。