Skip to content

[PR] fix: OpenAI proxy lane drops delta.reasoning — client keeps only first thinking token - #7434

Closed
ranxianglei wants to merge 3 commits into
masterfrom
2026-11-21_delta-reasoning-alias
Closed

ranxianglei wants to merge 3 commits into
masterfrom
2026-11-21_delta-reasoning-alias

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

OpenAI-wire upstreams disagree on the streaming reasoning field name: the standard is reasoning_content, but Ollama Cloud (and some others) emit delta.reasoning. The proxy-lane SSE parser (src/loop/adapter-openai.ts) read only reasoning_content, so a provider streaming under delta.reasoning lost its whole thinking block — the client kept exactly the first token (the role-carrying frame hit the meta fallback; every later frame fell through all dispatch branches and was dropped). Same bug family on the request side: kernel/src/wire/openai.ts openaiToCore read only m.reasoning_content, so a client echoing history under reasoning produced 0 reasoning cores.

Fix

  • Read side accepts the alias (reasoning_content → reasoning → reasoning_text, first non-empty, mirroring the client's reasoningFields order).
  • Forward frame normalized to reasoning_content — the client-visible field name stays stable and the history echo never trips an upstream that silently drops a reasoning field (empirical: reasoning_content echo → upstream 200 + CoT reuse; reasoning echo → upstream 200 but reasoning frames=0).
  • withheldProseFrame (tool-call replay path) recognizes the alias.
  • Kernel openaiToCore reads the alias; write side (coreToOpenai) stays reasoning_content.
  • OpenAIMessage gains the optional reasoning field.

kernel-change

kernel/src/wire/openai.ts openaiToCore read only m.reasoning_content; a client echoing prior-turn thinking under reasoning (Ollama Cloud) produced 0 reasoning cores and coreToOpenai dropped it. Read side now accepts the alias (first non-empty wins); write side stays reasoning_content. Mechanical-bug exemption: provably-correct alias read mirroring the host fix; reproducing regression tests added (kernel unit + host integration). Human review tier still gates the merge.

Bumps kernel 0.0.201 → 0.0.202 (master already carried 0.0.201 from an earlier kernel PR; branch rebased onto current master).

Tests

  • Host: tests/openai-reasoning-content.test.ts — trigger (delta.reasoning → kind:reasoning + raw frame normalized to reasoning_content), non-triggers (delta.reasoning_content unchanged; plain text frame produces no reasoning event), plus the reasoning_text alias case and the [bug] ACP 标签泄漏:<acp tokens=...> 标签被模型原样复述到回复正文,仅靠系统提示劝阻不足 #1881 withheld-sibling-prose alias case — the two latter absorbed with credit from the parallel host-only PR [PR] fix: read the delta.reasoning alias in the OpenAI adapter (#7432) #7433 (JamesYuuu), which duplicates this one (labeled duplicate/superseded; its unique coverage now lives here, commit 5fa66e6).
  • Kernel: kernel/tests/wire-reasoning-echo.test.ts — alias read + echoed as reasoning_content; blank alias keeps the blank-echo contract; reasoning_content wins over the alias when both present.
  • Targeted local runs green on the rebased head (host 15/15, kernel wire-reasoning-echo 11/11, verif-subset-guard 2/2, host+kernel typecheck clean); full-suite verdict = remote CI.

Closes #7432

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-21_delta-reasoning-alias (5fa66e6)

Latest build — install this exact version

npm install -g billion-context@0.0.11157-pr.7434.e627033

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
5fa66e6 billion-context@0.0.11157-pr.7434.e627033 build
96c6b21 billion-context@0.0.11153-pr.7434.3d8e518 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr7434.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: OpenAI proxy lane drops delta.reasoning — client keeps only first thinking token [PR] fix: OpenAI proxy lane drops delta.reasoning — client keeps only first thinking token Nov 21, 2026
ci-check added 3 commits November 21, 2026 12:50
…rame to reasoning_content (#7432)

OpenAI-wire upstreams disagree on the streaming reasoning field name: the
standard is reasoning_content, but Ollama Cloud (and some others) emit
delta.reasoning. The proxy-lane SSE parser read only reasoning_content, so a
provider streaming under delta.reasoning lost its whole thinking block — the
client kept exactly the first token (the role-carrying frame hit the meta
fallback; every later frame fell through all dispatch branches and was
dropped).

Read side now accepts the alias (reasoning_content -> reasoning ->
reasoning_text, first non-empty, mirroring the client's reasoningFields
order); the frame forwarded to the client is normalized back to
reasoning_content so the client-visible field name stays stable and the
history echo never trips an upstream that silently drops a reasoning field.
withheldProseFrame (tool-call replay path) recognizes the alias too.

Regression tests: trigger (delta.reasoning -> kind:reasoning + raw frame
normalized) and non-trigger (delta.reasoning_content unchanged; plain text
frame produces no reasoning event).

Closes #7432
…g_content (#7432)

kernel-change: openaiToCore (kernel/src/wire/openai.ts) read only
m.reasoning_content when converting an assistant history message to core, so a
client that echoes its prior-turn thinking under the reasoning field (Ollama
Cloud) produced 0 reasoning cores and coreToOpenai dropped it — the second
face of #7432 on the request side.

Read side now accepts the alias (reasoning_content -> reasoning, first
non-empty wins); the write side (coreToOpenai) stays reasoning_content — an
upstream that silently drops a reasoning field would lose the CoT reuse.
OpenAIMessage gains the optional reasoning field.

Mechanical-bug exemption: provably-correct alias read mirroring the host fix;
reproducing regression tests added (kernel unit + host integration). Human
review tier still gates the merge.

Bumps kernel 0.0.200 -> 0.0.201.

Closes #7432
…7432)

Two coverage gaps this PR's own implementation leaves untested:
- the #1881 withheld-sibling-prose path (proxy-only tool frame) now reads
  the reasoning alias but no test drives it;
- the third alias (reasoning_text) is in the read chain but untested.

Both cases mirror the test shapes contributed by PR #7433 (JamesYuuu),
the parallel host-only fix for the same issue, whose unique coverage this
absorbs before that PR is superseded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

1 participant