Skip to content

Commit 8f7ae96

Browse files
author
陈家名
committed
fix: make reasoning.exclude option actually suppress reasoning tokens
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.
1 parent b6cc513 commit 8f7ae96

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

sdk/src/impl/llm.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -711,21 +711,20 @@ export async function* promptAiSdkStream(
711711
throw chunkValue.error
712712
}
713713
if (chunkValue.type === 'reasoning-delta') {
714-
for (const provider of ['openrouter', 'codebuff'] as const) {
715-
if (
714+
const reasoningExcluded = (['openrouter', 'codebuff'] as const).some(
715+
(p) =>
716716
(
717-
params.providerOptions?.[provider] as
717+
params.providerOptions?.[p] as
718718
| OpenRouterProviderOptions
719719
| undefined
720-
)?.reasoning?.exclude
721-
) {
722-
continue
720+
)?.reasoning?.exclude,
721+
)
722+
if (!reasoningExcluded) {
723+
yield {
724+
type: 'reasoning',
725+
text: chunkValue.text,
723726
}
724727
}
725-
yield {
726-
type: 'reasoning',
727-
text: chunkValue.text,
728-
}
729728
}
730729
if (chunkValue.type === 'text-delta') {
731730
if (!params.stopSequences) {

0 commit comments

Comments
 (0)