Repository navigation
fix(core): turn off Workers AI thinking through the chat template - #52017
Merged
Merged
Conversation
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.
Issue for this PR
No linked issue.
Type of change
What does this PR do?
Workers AI used the generic Chat variant builder, which sends every catalog effort as
reasoning_effort. That caused two problems:nonevariant does not turn thinking off. The Chat endpoint acceptsreasoning_effort: "none"but ignores it on deepseek-v4-flash, deepseek-v4-pro, gemma-4 and glm-5.2; only kimi-k2.6 honors it. (Cloudflare's model metadata listsnoneas supported, which is where the catalog value comes from.)Workers AI now gets its own builder, like NVIDIA, Baseten and the other hosting providers already have:
noneand toggle-off sendchat_template_kwargs: { enable_thinking: false, thinking: false }, and toggle-on sends both astrue. Cloudflare's per-model input schemas documentchat_template_kwargs.enable_thinkingas the reasoning switch. Kimi's template readsthinkinginstead, so both keys are sent.reasoning_effort, which works.How did you verify your code works?
packages/core/test/variant.test.ts(fails without the change).bun typecheckpasses inpackages/core.opencode run --standalone -m cloudflare-workers-ai/<model>#<variant>through a logging proxy, counting reasoning in the response and in the stored message:#none#none#none#none#none#none/#thinking#none, nemotron#none#none, kimi-k2.6#none, qwen3.8#noneand glm-4.7-flash#thinkingall complete, and prompt cache reads still appear on later steps.Screenshots / recordings
Not applicable.
Checklist