Skip to content

fix(providers): 中继 reasoning summary 正文漏进回答 — 按步骤终态分流#146

Merged
sweetcornna merged 2 commits into
mainfrom
fix/relay-reasoning-summary-leak
Jul 18, 2026
Merged

fix(providers): 中继 reasoning summary 正文漏进回答 — 按步骤终态分流#146
sweetcornna merged 2 commits into
mainfrom
fix/relay-reasoning-summary-leak

Conversation

@sweetcornna

Copy link
Copy Markdown
Owner

修复 #145 之后用户报告的聊天问题:gpt-5.6-sol(Responses→chat.completions 中继)把 reasoning summary 的标题发到 delta.reasoning_content(单 chunk **…**),而 summary 正文当普通 delta.content 流下来 → 规划文字被渲染成助手正文,且跨步骤无分隔拼接。

修法(provider 流式状态机):

  • 标题型 reasoning chunk(**…** 整块)之后的 content 进入缓冲
  • 步骤出现 tool_call / finish=tool_calls → 缓冲=规划文字,冲入 reasoning 块
  • finish=stop 或缓冲超 4KB → 缓冲=真答案,原样流回 content
  • DeepSeek-R1 式多 chunk 推理不会命中标题门,答案照常实时流式
  • summary part 之间补空行;前端 reducer 对跨步骤标题粘连补段落分隔

验证:直连中继复现原始 SSE 形态(标题→正文→tool_calls)后按形态建模;新增 6 个离线流测试;providers 538 测试 + agent reasoning 101 测试 + ui 1153 测试全绿;既有 R1 测试抓住并修正了一个分隔符实现瑕疵。

Responses→chat.completions shims (observed: gpt-5.x behind
OpenAI-compatible relays) split each reasoning-summary part across two
fields: the bold headline arrives as a single delta.reasoning_content
chunk (**…**) while the part's BODY streams as plain delta.content. The
planning prose then rendered as the assistant's reply, concatenated
across steps without separators.

Provider stream loop now runs a small state machine: after a
headline-only reasoning chunk, content deltas buffer; a tool-call delta
or finish=tool_calls proves the buffer was planning prose → flushed into
the reasoning block; finish=stop or outgrowing the 4KB summary cap
proves it was the real answer → flushed back as ordinary content.
DeepSeek-R1-style multi-chunk reasoning prose never matches the headline
gate, so real answers keep streaming live. Summary parts join with blank
lines; the chat reducer also inserts a paragraph break when a new
headline lands flush against the previous step's reasoning.

Verified against the live relay wire shape (headline via
reasoning_content → body via content → tool_calls) and covered by six
new offline stream tests.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added codex:needs-review A Codex review is needed for the current PR head. codex:review-requested A Codex review was requested or should be running automatically. status: 🔁 re-review loop A fresh Codex review was requested after the latest change or comment. codex:reviewed Codex posted a review result or thumbs-up after the latest request. status: 👀 ready for maintainer look No automation blocker is known; a maintainer should inspect the current result. and removed codex:review-requested A Codex review was requested or should be running automatically. codex:needs-review A Codex review is needed for the current PR head. status: 🔁 re-review loop A fresh Codex review was requested after the latest change or comment. labels Jul 18, 2026
@github-actions github-actions Bot added codex:needs-rerun A new push or stale result means @codex review should be requested again. codex:review-requested A Codex review was requested or should be running automatically. status: 🔁 re-review loop A fresh Codex review was requested after the latest change or comment. and removed codex:reviewed Codex posted a review result or thumbs-up after the latest request. status: 👀 ready for maintainer look No automation blocker is known; a maintainer should inspect the current result. labels Jul 18, 2026
@sweetcornna
sweetcornna merged commit 8c4c329 into main Jul 18, 2026
9 checks passed
@sweetcornna
sweetcornna deleted the fix/relay-reasoning-summary-leak branch July 18, 2026 13:58
@github-actions github-actions Bot added status: ✅ merge-ready Evidence and review are clear; normal merge gates may proceed. and removed codex:review-requested A Codex review was requested or should be running automatically. codex:needs-rerun A new push or stale result means @codex review should be requested again. status: 🔁 re-review loop A fresh Codex review was requested after the latest change or comment. labels Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ✅ merge-ready Evidence and review are clear; normal merge gates may proceed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant