From 8f7ae96f152114663f0307c79a7be781b2bb5337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AE=B6=E5=90=8D?= Date: Sun, 5 Apr 2026 16:17:43 +0800 Subject: [PATCH] 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. --- sdk/src/impl/llm.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sdk/src/impl/llm.ts b/sdk/src/impl/llm.ts index 8d20515536..8fc68f24c9 100644 --- a/sdk/src/impl/llm.ts +++ b/sdk/src/impl/llm.ts @@ -711,21 +711,20 @@ export async function* promptAiSdkStream( throw chunkValue.error } if (chunkValue.type === 'reasoning-delta') { - for (const provider of ['openrouter', 'codebuff'] as const) { - if ( + const reasoningExcluded = (['openrouter', 'codebuff'] as const).some( + (p) => ( - params.providerOptions?.[provider] as + params.providerOptions?.[p] as | OpenRouterProviderOptions | undefined - )?.reasoning?.exclude - ) { - continue + )?.reasoning?.exclude, + ) + if (!reasoningExcluded) { + yield { + type: 'reasoning', + text: chunkValue.text, } } - yield { - type: 'reasoning', - text: chunkValue.text, - } } if (chunkValue.type === 'text-delta') { if (!params.stopSequences) {