Add a `_default_reasoning_effort` knob and remove the dead `_initial_effort` line

#91
by gdevenyi - opened

Summary

Users who cannot pass chat_template_kwargs (LM Studio and similar UIs) have no working way to change the default reasoning effort. A user in peculiar-ragdoll/Qwen-Sharp-Chat-Templates#3 (same code as here) edited {%- set _initial_effort = 'medium' %} to 'xhigh' and saw no effect. That is expected: _effort_raw falls back to the literal 'medium' two lines above, and the if/elif/else that follows always overwrites _initial_effort, so that line is dead code.

Changes

  • chat_template.jinja: one knob, {%- set _default_reasoning_effort = 'medium' %}, with a one-line Jinja comment, used as the fallback for _effort_raw. The dead _initial_effort = 'medium' line is removed (the else branch still sets 'medium'). Setting the knob to 'none' defaults to non-thinking mode; an explicit reasoning_effort kwarg still overrides the knob. Rendering with no kwargs is byte-identical to before.
  • chat_template_oneline.txt: regenerated with scripts/minify_jinja.py (the comment is stripped there, as all comments are).
  • scripts/test_v22.py: new test 24c renders a patched copy of the template with the knob set to 'xhigh' and 'none', checks the stock default injects nothing, and checks an explicit kwarg still wins.
  • README.md: a short "Editing defaults without kwargs" list in the reasoning-effort section, naming the three top-of-file defaults (_default_reasoning_effort, enable_thinking, _tool_format — the last one is what #79 already tells LM Studio MLX users to edit).

The {#- … #} comment form is accepted by minja (comment_tok regex allows the - trim marker) as well as Jinja2, so llama.cpp / LM Studio / oMLX / vLLM all parse it.

Verification

python3 scripts/test_v22.py → 101/101, and again with QWEN_TEMPLATE_FILE=chat_template_oneline.txt → 101/101; python3 scripts/test_v21.py → 9/9; python3 scripts/fuzz_template.py --cases 300 → clean.

Merged. Putting _default_reasoning_effort right at the top makes it way simpler for LM Studio users who just want to tweak the default without messing with the mapping block.

froggeric changed pull request status to closed

Sign up or log in to comment