server: respect per-request enable_thinking toggle via extra_body#22336
Open
pju-hoge wants to merge 1 commit into
Open
server: respect per-request enable_thinking toggle via extra_body#22336pju-hoge wants to merge 1 commit into
pju-hoge wants to merge 1 commit into
Conversation
Fix enable_thinking being ignored in llama.cpp server requests. The issue was in three places: - server-common.cpp: read enable_thinking from extra_body directly (not just chat_template_kwargs), and propagate it to chat_template_kwargs for template access - common/chat.cpp: supports_thinking = template_supports_thinking && params.enable_thinking - common/chat-auto-parser-generator.cpp: extract_reasoning depends on inputs.enable_thinking API usage: - reasoning_format='auto' + extra_body.enable_thinking=true -> thinking on - reasoning_format='auto' + extra_body.enable_thinking=false -> thinking off
|
Hi @pju-hoge, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
Contributor
|
As far as I'm aware, Also, the general way to "disable" thinking with reasoning models is to add empty |
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.
Overview
Fixes
enable_thinkingbeing ignored when set per-request viaextra_bodyorchat_template_kwargs. Previously the server only checkedchat_template_kwargs, but OpenAI-compatible clients (and tools like Opencode) send it inextra_body. This causedenable_thinking: falseto be silently ignored across all shells.Changes
tools/server/server-common.cppRead
enable_thinkingfromextra_bodyfirst (OpenAI-compatible path), then fall back tochat_template_kwargs. Pass the value to the slot so it can override the server default.common/chat.cppsupports_thinkingnow requires both template-level reasoning detection ANDenable_thinking == true. Prevents thinking tags from being injected when the user explicitly toggles thinking off.common/chat-auto-parser-generator.cppextract_reasoningalso gated byenable_thinking, ensuring the PEG parser does not extract reasoning block markers when thinking is disabled.Fixes
enable_thinkingparam cannot turn off thinking for qwen3.5enable_thinking=falseignored across all shellsTesting
cmake --build . -j$(nproc))test-chatandtest-chat-peg-parserpassAI Usage Disclosure
YES — AI (OpenCode with Qwen3.6-35B) assisted with code formatting, searching related issues on GitHub, verifying CI compliance against
.github/workflows/server.yml, and drafting this PR description. All code changes, logic design, and review were performed by the contributor.