Skip to content

feat(server): derive the thinking_mode chat-template kwarg when the template supports it #775

Closed

Description

@inureyes

Summary

Some chat templates gate reasoning on a thinking_mode string variable rather than the boolean enable_thinking. mlxcel already derives an enable_thinking default from the template (src/server/chat_template.rs:147-169) and has generic template-kwarg plumbing (src/server/chat_template_kwargs.rs), but it never sets thinking_mode, so such templates silently fall back to the non-thinking branch even when thinking is requested.

Semantics

When thinking is enabled for a request (explicitly or by default) AND the raw chat template text references the identifier thinking_mode, inject thinking_mode: "enabled" into the template kwargs, unless the client already supplied a thinking_mode kwarg. Inject nothing when thinking is disabled (templates default the variable themselves).

Implementation plan

  1. Template-reference check: a substring scan of the template source for thinking_mode, in the same style as the existing enable_thinking detection in chat_template.rs.
  2. Inject during kwarg resolution in chat_template_kwargs.rs, with client-provided values winning.
  3. Tests: a template gated on thinking_mode renders the thinking branch when enabled; a client override is respected; templates without the identifier are untouched.

Acceptance criteria

  • Unit tests pass; rendering for existing templates (qwen3 family, gemma family) is unchanged.

Effort: low.

Activity

  1. added
    type:enhancement
    priority:low
    status:ready
    status:in-progress
    status:review
    status:done
    and removed
    status:ready
    status:in-progress
    status:review
    on Jul 13, 2026
  2. added a commit that references this issue on Jul 17, 2026
    6f93183
  3. self-assigned this
    on Aug 31, 2026
  4. added a commit that references this issue on Oct 27, 2026
    b3518b6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority:lowstatus:donetype:enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions