Skip to content

feat: distinguish thinking models #406

Open

Description

@jakelorocco

Problem

Mellea has no way to know at session setup (or call time) that a model supports thinking / extended reasoning. This matters because:

  • vLLM + Granite: thinking tier is controlled via chat_template_kwargs in extra_body — a vLLM-specific field. There is no standard way to forward a thinking tier (NOTHINK / LIGHT / DEEP) without knowing the model supports it and what the field name is.
  • HF / transformers: thinking is controlled by a Jinja template variable (think or thinking depending on the model family). The variable name is not standardised across models. We currently silently drop ModelOption.THINKING — see enhancement: huggingface should handle ModelOption.THINKING #1212.
  • Ollama / LiteLLM: similar provider-specific variations.

The practical consequence: callers who want thinking enabled must hard-code provider-specific parameters rather than using a portable Mellea abstraction. There is no error when thinking is requested but silently ignored.

Proposed direction

Rather than a single global model registry, the approach should be per-backend capability detection:

  1. Each backend exposes whether the loaded model supports thinking (detected from the chat template, model card, or an explicit override).
  2. ModelOption.THINKING (already defined) is mapped to the correct provider-specific parameter by the backend — e.g. chat_template_kwargs: {enable_thinking: true} for vLLM, think: true for HF Granite.
  3. A common ModelCapability.THINKING flag (or similar) can be surfaced on the backend so callers can branch on it if needed.

The default_extra_body addition on OpenAIBackend (#1453) is the immediate unblocking step for vLLM. This issue covers the higher-level abstraction that makes thinking portable across backends.

Out of scope

  • Training or fine-tuning thinking models.
  • Controlling thinking budget as a first-class concept (that's a follow-on once the basic flag works).

Acceptance criteria

  • ModelOption.THINKING forwarded correctly to Granite on both the HF and OpenAI-compatible backends without any provider-specific caller code.
  • Silent drop of ModelOption.THINKING is replaced by either correct forwarding or an explicit UnsupportedModelOption warning.
  • At least one e2e test demonstrating thinking enabled vs disabled on Granite 4.1 via Ollama or vLLM.

Related

Activity

  1. added
    documentation
    enhancement
    and removed
    documentation
    on May 12, 2026
  2. psschwei commented on May 12, 2026

    @psschwei
    Contributor

    still open question on whether this is something we should do, not high priority

  3. added
    area/stdlib
    area/component
    on May 20, 2026
  4. added
    p2
    on Jun 18, 2026
  5. planetf1 commented on Aug 5, 2026

    @planetf1
    Contributor

    Adding a concrete use-case for vLLM + Granite, since this issue sits at the intersection of "thinking models" and Mellea integration.

    The specific problem: vLLM's Granite thinking tier is controlled via chat_template_kwargs in extra_body — a vLLM-specific field not in the OpenAI spec. To forward a thinking tier (NOTHINK/LIGHT/DEEP) into Mellea's draft calls, you'd need:

    backend = OpenAIBackend(
        ...,
        model_options={"extra_body": {"chat_template_kwargs": {"enable_thinking": True}}}
    )

    This does not work today because extra_body in model_options hits the collision bug fixed in PR #1204 (intrinsic path still needs the fix per #1241). And even after that fix, there's no clean construction-time equivalent.

    What we'd want: Either a default_extra_body on OpenAIBackend (see #1453), or a per-call model_options override on instruct() (see #1452), so thinking tier can be specified once without tearing down the session.

    Beyond the API surface, a higher-level thinking_tier concept on OpenAIBackend could abstract away the vLLM-specific chat_template_kwargs — which is what this issue originally proposed. We'd be interested in that direction too.

  6. added
    needs-design
    on Aug 10, 2026
  7. added
    area/backends
    on Aug 19, 2026
  8. added
    area/thinking
    on Sep 9, 2026
  9. planetf1 commented on Sep 9, 2026

    @planetf1
    Contributor

    One more thing worth scoping into this design: Granite 4.2 defaults to thinking ON if ModelOption.THINKING is omitted entirely (enable_thinking if defined else True in the chat template — see mellea/backends/model_options.py:74). There's no safe no-op default here; every call against a Granite 4.2 model pays full reasoning cost (tokens + latency) unless the caller explicitly sets THINKING=False.

    Any unified ModelCapability.THINKING abstraction should make this default explicit and documented per-model (not just NOTHINK/LOW/DEFAULT as states, but which one a given model lands on when unset) — otherwise the abstraction just relocates the current surprise-cost problem rather than fixing it.

    Also linked two standalone bugs found while investigating this (#1636, #1637) — both prerequisites/related, not folded into this design issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/backendsarea/componentarea/stdlibarea/thinkingenhancementneeds-designp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions