Skip to content

[BUG] 开启思考模式(enable_thinking=true)后,携带 response_format 的请求返回的 content 与模型自身 reasoning_content 中已经写定的结论不一致 #2329

Description

@flying-dolphin

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

  • 我已经搜索过已有的issues和讨论 | I have searched the existing issues / discussions

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

  • 我已经搜索过FAQ | I have searched FAQ

当前行为 | Current Behavior

问题:思考模式下携带 response_format 时,最终回复会偏离模型自己的思考定稿。

在百炼 OpenAI 兼容接口上调用 qwen3.8-max / qwen3.8-flash 等思考模型时:

  • 请求携带 response_format={"type": "json_object"}:返回的 content 是合法 JSON,但其结论与同一次调用的 reasoning_content 结尾处模型已经写定的结论不一致,并且会出现整段 reasoning_content 中从未出>现过的数值。
  • 请求不携带 response_formatcontentreasoning_content 的定稿逐字一致

两者唯一的差别就是 response_format 这一个参数,messages、seed、模型、其余参数完全相同。

期望行为 | Expected Behavior

使用思考模式+response_format={"type": "json_object"}时,最终的返回结果跟思考模式的结论一致。

复现方法 | Steps To Reproduce

用同一组 messages、同一 seed 连发两次请求
唯一变量是是否携带response_format={"type": "json_object"}。对比content和reasoning_content的结论是否一致。

运行环境 | Environment

|||
| --- | --- |
| 接入方式 | OpenAI 兼容接口 |
| base_url | https://dashscope.aliyuncs.com/compatible-mode/v1 |
| 模型 | qwen3.8-max、qwen3.8-flash、qwen3.8-27b、第三方的glm-5.2和kimi-k3 均可复现 |
| SDK | openai-python 2.8.1 |
| Python | 3.12.13 |
| 关键参数 | `extra_body={"enable_thinking": True}``stream=True``seed` 固定;未设置 `max_tokens`、未设置 `temperature` |

备注 | Anything else?

我们已经排除的因素

  1. 字段读取choices[0].message.content / .reasoning_content,与官方非流式示例一致;返回体中不存在第三个正文字段。
  2. 流式与非流式:两种方式表现一致,不是解析流式增量导致的。
  3. max_tokens:全程未设置(已知文档要求结构化输出时不要设置)。
  4. temperature:我们默认不设置;额外测试 temperature=0.05,偏差不但没有消失,反而更大。
  5. 请求体:仅 model / messages / response_format / extra_body.enable_thinking 四个键,无其它参数干扰。
  6. json_object 与 json_schema:两种结构化模式都会出现,不是某一种模式特有。
  7. 模型范围:qwen3.8-max、qwen3.8-flash、qwen3.8-27b、glm-5.2、kimi-k3 均可复现;但是我用GLM的官方API测试则没有出现这个问题,content和reasoning_content是一致的。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions