From 608c8e222349f0e92ad1828e45041f4565beaa1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AE=B6=E5=90=8D?= <13774486042@163.com> Date: Mon, 6 Apr 2026 07:13:32 +0800 Subject: [PATCH] fix: make reasoning.exclude option actually suppress reasoning tokens (#495) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 陈家名 --- 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) {