Repository navigation
fix(sse): reasoning_content placeholder skips messages already carrying the reasoning alias - #18273
Merged
diegosouzapw merged 2 commits intoOct 27, 2026
Conversation
…arry the reasoning alias The thinking-model placeholder injector only looked at a string reasoning_content. An assistant message carrying the `reasoning` alias, or an array-valued carrier, got a second reasoning_content, and serde-based upstreams (DeepSeek, Kimi, GLM) reject that body with `duplicate field reasoning_content`. The injector now skips any message with a non-empty string or array in either reasoning_content or reasoning; messages with no carrier still get the placeholder. Co-authored-by: AppleVibe <AppleVibe@users.noreply.github.com> Inspired-by: decolua/9router#4881
diegosouzapw
deleted the
fix/port-pr-4881-reasoning-injector-alias-idempotent
branch
October 28, 2026 09:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
reasoning_contentplaceholder injector (OpenCode thinking models, Kimi/Moonshot andrequiresReasoningContentEchoregistry entries) only treated a stringreasoning_contentas present. An assistant message carrying thereasoningalias, or an array-valued carrier, got a secondreasoning_content, and serde-based upstreams (DeepSeek, Kimi, GLM) reject that body with400 duplicate field reasoning_content.reasoning_contentorreasoning. Messages with no carrier still get the placeholder (unsupported_country_region_territory (bug?) #1543 contract kept).reasoningintoreasoning_contenton replay turns) already landed in fix(sse): drop reasoning alias once reasoning_content carries the replay #16646. The injector does not rename or delete the alias.Attribution
Thanks to @AppleVibe for the original implementation.
Changes
open-sse/utils/reasoningContentInjector.ts:hasNonEmptyReasoningContent→hasAnyReasoningCarrier(string or array,reasoning_contentorreasoning; strings keep the.trim()semantics).tests/unit/reasoningContentInjector.test.ts: 6 new cases (alias-only, both carriers, arrayreasoning_content, arrayreasoning, no carrier, whitespace/empty carriers still injected).reasoning_details(OpenRouter shape) deliberately not counted as a carrier, same as the original fix; no test needs it.Test plan
node --import tsx/esm --test tests/unit/reasoningContentInjector.test.ts→ℹ tests 11 ℹ pass 8 ℹ fail 3(alias-only, arrayreasoning_content, arrayreasoning). After:ℹ tests 11 ℹ pass 11 ℹ fail 0.reasoningContentInjectororreasoning_content(150 files,test:unit:cipreamble, concurrency 4):ℹ tests 2207 ℹ pass 2195 ℹ fail 12. All 12 failures were intests/unit/deepseek-web.test.ts(10 sAbortSignal.timeouton PoW under load average ~17; this executor does not import the injector). Rerun alone at lower load:ℹ tests 35 ℹ pass 35 ℹ fail 0.ℹ tests 26 ℹ pass 8 ℹ fail 0 ℹ skipped 18(live/e2e suites skip without credentials).npx eslint --suppressions-location config/quality/eslint-suppressions.json <changed files>→ exit 0;npx prettier --check <changed files>→ clean.npm run typecheck:core→ exit 0.GITHUB_BASE_REF=release/v3.8.53 node scripts/check/check-pr-test-policy.mjs→Result: PASS;GITHUB_BASE_REF=release/v3.8.53 npm run check:test-masking→OK — 1 modificado(s) … sem enfraquecimento.