Skip to content

openai-chat 流门控不识别 OpenRouter 兼容上游的 delta.reasoning / reasoning_details,长推理被误判为 prebuffer_overflow #1509

Open

Description

@Lynricsy

现象

openai-compatible 供应商对接 OpenRouter 兼容上游(实测 Cline API https://api.cline.bot/api/v1,中间经 Sub2API 透传),流式请求推理模型(deepseek-v4.1-flash)时,凡是思考阶段超过 64 帧的请求,CCH 都返回 502:

Stream content gate rejected upstream before first valid content (prebuffer_overflow)
{"error":{"type":"stream_gate_precommit","reason":"prebuffer_overflow","family":"openai-chat","frames_seen":65,"buffered_bytes":22867}}

同 provider 重试同样失败,客户端最终收到 503「所有供应商暂时不可用」。上游侧对应请求是 HTTP 200,并且返回了完整输出和用量,所以上游日志里看不到任何错误。思考较短(少于 64 帧)的请求能正常返回,因此表现为间歇性失败。

原因

OpenRouter 兼容上游的推理增量不放在 reasoning_content 字段(DeepSeek 方言,#1395 已支持),而是放在 delta.reasoning 和 delta.reasoning_details[] 里,content 字段缺省。下面是直连上游抓到的帧:

{"choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
{"choices":[{"index":0,"delta":{"reasoning":"We","reasoning_details":[{"type":"reasoning.text","text":"We","format":"unknown","index":0}]},"finish_reason":null}]}
...
{"choices":[{"index":0,"delta":{"content":"No"},"finish_reason":null}]}

frame-classifier.ts 中 openai-chat 的 contentRules 只识别 delta.content 和 delta.reasoning_content,不识别上面这两个字段,所以推理帧全部被判为 neutral。累计超过 STREAM_GATE_PREBUFFER_EVENT_CAP(默认 64)后触发 prebuffer_overflow。prebuffer_overflow 不属于 request-scoped,会计入熔断,持续发生时会把整个供应商熔断。

reasoning_details[] 的条目类型参见 OpenRouter 文档:reasoning.text(text)、reasoning.summary(summary)、reasoning.encrypted(data)。

期望

非空的 delta.reasoning,以及 delta.reasoning_details[].text / .summary / .data,应当与 reasoning_content 一样被识别为首个有效内容;值为空时仍判为 neutral。

环境

  • CCH v0.9.4,origin/dev(v0.9.7)中的规则相同
  • 供应商类型:openai-compatible,/v1/chat/completions,stream: true

Activity

  1. added
    stale
    on Nov 15, 2026
  2. github-actions commented on Nov 15, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had any activity in the last 30 days.

    If this issue is still relevant:

    • Please comment to keep it open
    • Add any new information that might help resolve it

    This issue will be automatically closed in 14 days if there is no further 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

    stale

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions