Skip to content

fix: make reasoning.exclude option actually suppress reasoning tokens#495

Open
hiSandog wants to merge 1 commit intoCodebuffAI:mainfrom
hiSandog:fix/reasoning-exclude-loop-scope
Open

fix: make reasoning.exclude option actually suppress reasoning tokens#495
hiSandog wants to merge 1 commit intoCodebuffAI:mainfrom
hiSandog:fix/reasoning-exclude-loop-scope

Conversation

@hiSandog
Copy link
Copy Markdown
Contributor

@hiSandog hiSandog commented Apr 5, 2026

Summary

The reasoning.exclude option in providerOptions for OpenRouter/Codebuff providers was completely non-functional. Setting providerOptions.openrouter.reasoning.exclude = true would not suppress reasoning tokens from the stream.

Root Cause

In sdk/src/impl/llm.ts, the continue statement was inside an inner for loop over providers, so it only skipped to the next provider iteration — the yield on the following line was unconditionally reached regardless.

Fix

Replaced the inner for loop with .some() so the exclude flag correctly controls whether reasoning chunks are yielded:

const reasoningExcluded = (['openrouter', 'codebuff'] as const).some(
  (p) =>
    (params.providerOptions?.[p] as OpenRouterProviderOptions | undefined)
      ?.reasoning?.exclude,
)
if (!reasoningExcluded) {
  yield { type: 'reasoning', text: chunkValue.text }
}

Validation

  • Logic verified manually — change is purely structural, no semantic difference in the check itself
  • Type signature unchanged — OpenRouterProviderOptions type still used identically

The previous implementation used a `continue` inside an inner for-loop,
which only skipped to the next provider iteration instead of preventing
the `yield` of reasoning-delta chunks. Replaced with `.some()` so the
exclude check correctly controls whether to yield the reasoning chunk.
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