Skip to content

fix(provider): stream gateway reasoning_content as exposed thinking (RR8.2) - #199

Merged
lg2m merged 2 commits into
fix/eng-953-rr8-empty-truncationfrom
fix/eng-954-rr8-gateway-reasoning
Sep 28, 2026
Merged

lg2m merged 2 commits into
fix/eng-953-rr8-empty-truncationfrom
fix/eng-954-rr8-gateway-reasoning

Conversation

@lg2m

@lg2m lg2m commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

RR8.2: Chat Completions codec streams reasoning_content

Spec: docs/plans/run-reliability.md (RR8) Linear: ENG-954 Stack: 2/4, on ENG-953

What changed

  • ChatDelta now decodes reasoning_content (LiteLLM / DeepSeek / vLLM) and reasoning (OpenRouter); both are absent from OpenAI's own responses.
  • The stream frames fragments as one ReasoningKind::ExposedThinking block: opened on the first fragment, closed by the first visible delta, finish reason, or [DONE]. Bytes count against the output bound like the Anthropic adapter.
  • Effect: a 16 384-token all-thinking turn is visible live in the TUI as reasoning followed by Incomplete, never an empty turn. This is what made the RR8.1 failure invisible.

How verified

  • decodes_gateway_reasoning_content_ahead_of_visible_content
  • streams_gateway_reasoning_as_one_block_closed_by_visible_output (loopback SSE)
  • an_all_reasoning_turn_cut_at_length_closes_its_block_before_incomplete (the audited shape, with trailing usage)
  • Minimal provider profile green.

Docs

  • docs/design/providers.md § reasoning effort.

Compatibility

  • Wire request unchanged. No protocol change.

Evidence

Operator store, read-only: two provider_output_truncated runs on litellm/us.anthropic.claude-fable-5-1 (2026-09-23, 2026-09-25). Every failing turn persisted assistant_content_json = [] with output_tokens = 16384; every continuation request had input_tokens = 2 uncached (byte-identical resend). Route-wide since 09-10: 3 935 turns, 49 truncated, 31 empty, ≈ 671 k output tokens and ≈ 2 h wall producing nothing.

Review round (Codex)

Gates (run on the stack tip and on this branch's tip)

  • cargo fmt --all -- --check ✅
  • cargo clippy --workspace --all-targets --all-features -- -D warnings ✅ (every branch tip)
  • cargo test --workspace ✅ all passing at the stack tip; each intermediate tip compiles and passes qq/qq-core/qq-provider on its own.
  • cargo test -p qq-provider --no-default-features --features test-support ✅ 184 passed.
  • wasm32 qq-client build ✅

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T05:17:56.658853Z 7ad1d6b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lg2m
lg2m added this pull request to stack #202 September 26, 2026 06:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2c0dd4ce4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/design/providers.md Resolved
Comment thread docs/design/providers.md Resolved
@lg2m
lg2m force-pushed the fix/eng-954-rr8-gateway-reasoning branch from f2c0dd4 to ed8eb49 Compare September 26, 2026 19:00
@lg2m
lg2m force-pushed the fix/eng-954-rr8-gateway-reasoning branch 2 times, most recently from 365de0e to f555920 Compare September 26, 2026 19:55
…RR8.2)

The Chat Completions codec ignored delta.reasoning_content, the field
LiteLLM, OpenRouter, DeepSeek and vLLM use for exposed thinking. An
all-thinking turn therefore looked empty to the runtime and the TUI, which
is how 16 384-token reasoning turns hid behind 'output token limit' failures.
The codec now frames the fragments as one ExposedThinking block (opened on
the first fragment; closed by the first visible delta, finish reason, or
[DONE]) and bounds the bytes like the Anthropic adapter does.

Tests: decodes_gateway_reasoning_content_ahead_of_visible_content,
streams_gateway_reasoning_as_one_block_closed_by_visible_output,
an_all_reasoning_turn_cut_at_length_closes_its_block_before_incomplete.

Linear: ENG-954
…ing (RR8.2 review)

OpenRouter's normalized Chat Completions stream carries exposed thinking as
`delta.reasoning`, not `delta.reasoning_content`; Serde silently dropped it,
so reasoning-only OpenRouter turns still looked empty. Both spellings decode
to the same reasoning delta (`reasoning_content` wins if a gateway sends both).

Linear: ENG-954
@lg2m
lg2m force-pushed the fix/eng-954-rr8-gateway-reasoning branch from f555920 to 7ad1d6b Compare September 28, 2026 05:13
@lg2m
lg2m merged commit 1ff593b into main Sep 28, 2026
7 of 8 checks passed
@lg2m
lg2m deleted the fix/eng-954-rr8-gateway-reasoning branch September 28, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant