Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions skillopt/model/qwen_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ def _chat_messages_impl(
"messages": _json_safe(messages),
"max_tokens": min(max_completion_tokens, config.max_tokens),
}
if config.enable_thinking:
payload["chat_template_kwargs"] = {"enable_thinking": True}
# Always send an explicit value: omitting it leaves thinking mode to the
# vLLM server / chat-template default, which varies across deployments (#90).
payload["chat_template_kwargs"] = {"enable_thinking": bool(config.enable_thinking)}
if config.temperature is not None:
payload["temperature"] = config.temperature
if tools:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_qwen_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _record_urlopen(
return recorder


def test_chat_target_omits_chat_template_kwargs_when_thinking_disabled(
def test_chat_target_sends_explicit_false_when_thinking_disabled(
monkeypatch: pytest.MonkeyPatch,
isolate_qwen_state: tuple[Any, Any],
) -> None:
Expand All @@ -167,7 +167,7 @@ def test_chat_target_omits_chat_template_kwargs_when_thinking_disabled(

assert text == "<answer>yes</answer>"
assert usage["total_tokens"] == 3
assert "chat_template_kwargs" not in recorder.calls[0]["payload"]
assert recorder.calls[0]["payload"]["chat_template_kwargs"] == {"enable_thinking": False}
assert recorder.calls[0]["timeout"] == 10.0


Expand Down Expand Up @@ -224,4 +224,4 @@ def test_configure_qwen_chat_runtime_toggle_controls_payload(
model_module.chat_target("system", "user", max_completion_tokens=128, retries=1)

assert recorder.calls[0]["payload"]["chat_template_kwargs"] == {"enable_thinking": True}
assert "chat_template_kwargs" not in recorder.calls[1]["payload"]
assert recorder.calls[1]["payload"]["chat_template_kwargs"] == {"enable_thinking": False}