fix(tokenizer): respect explicit enable_thinking=false even when tools present - #475
Open
rafaeldrincon wants to merge 1 commit into
Open
rafaeldrincon wants to merge 1 commit into
rafaeldrincon wants to merge 1 commit into
Conversation
…s present resolve_thinking_mode() forced mode='thinking' when tools were present, ignoring an explicit enable_thinking=False from the caller. This wasted generation budget on reasoning tokens for clients that explicitly requested no thinking while using tool calling. An explicit disable now takes precedence over the tools-presumed-thinking heuristic. Closes FlashML-org#474
This was referenced Sep 15, 2026
gdevenyi
added a commit
to gdevenyi/FreeToken
that referenced
this pull request
Sep 18, 2026
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.
Problem
resolve_thinking_mode()inpython/freetoken/tokenizer/tokenize.pyforcedmode = "thinking"whenevertoolswas non-None, ignoring an explicitenable_thinking: falsefrom the caller.This wastes generation budget on reasoning tokens for clients that want tool calling without thinking (e.g. agents using OpenAI-compatible providers that don't need chain-of-thought for tool selection).
Fix
An explicit
enable_thinking=False(orthinking=False) now returns"chat"immediately, before thetoolsheuristic runs.Tests
Added
test_explicit_disable_overrides_toolscovering:enable_thinking=False+ tools → chatthinking=False+ tools → chatenable_thinking=False, thinking=True+ tools → chat (explicit disable wins)thinking=False, enable_thinking=True+ tools → chat (explicit disable wins)All existing tests pass unchanged.
Closes #474
Test environment
Verified on real hardware: sending tools +
chat_template_kwargs={enable_thinking: false}to Qwen3.6-35B-A3B no longer generates reasoning tokens.