Skip to content

fix(tokenizer): respect explicit enable_thinking=false even when tools present - #475

Open
rafaeldrincon wants to merge 1 commit into
FlashML-org:mainfrom
rafaeldrincon:fix/thinking-mode-tools-override
Open

rafaeldrincon wants to merge 1 commit into
FlashML-org:mainfrom
rafaeldrincon:fix/thinking-mode-tools-override

Conversation

@rafaeldrincon

Copy link
Copy Markdown

Problem

resolve_thinking_mode() in python/freetoken/tokenizer/tokenize.py forced mode = "thinking" whenever tools was non-None, ignoring an explicit enable_thinking: false from 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 (or thinking=False) now returns "chat" immediately, before the tools heuristic runs.

Tests

Added test_explicit_disable_overrides_tools covering:

  • enable_thinking=False + tools → chat
  • thinking=False + tools → chat
  • enable_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

ft version: 0.1.2
model: nvidia/Qwen3.6-35B-A3B-NVFP4
gpu: RTX 3080 Ti Laptop (16GB, sm_86)
cuda: 13.1, driver: 580

Verified on real hardware: sending tools + chat_template_kwargs={enable_thinking: false} to Qwen3.6-35B-A3B no longer generates reasoning tokens.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tokenizer): resolve_thinking_mode ignores explicit enable_thinking=false when tools present

1 participant