Reasoning effort is the dashboard's to set, not the client's

One model is loaded at a time under one setting, and that setting belongs next
to the model it applies to -- the same reason the client can't switch models.
So the proxy now takes a client's reasoning settings off the request before
applying the dashboard's: a top-level reasoning_effort, and enable_thinking or
reasoning_effort inside chat_template_kwargs. Other template kwargs, which
llm-host has no opinion about, still pass through.

This reverses the precedence the proxy had (a client's own kwargs won, mirroring
mlx_lm's own rule), which was the wrong model for a single-model server: clients
offer a generic menu -- opencode's low/medium/high -- and a level the template
doesn't define makes it raise, so every request failed with nothing on the
user's screen to explain it.

- opencode: the provider block disables all three of opencode's effort levels
  instead of curating them. A chooser there would be a menu that does nothing.
- Deletes the nearest-effort mapping (EFFORT_SCALE, nearest_effort,
  plan.effort_levels, the effort_levels= parameter through both backends): it
  existed only to rescue a client-supplied level, and none survives now.
- plan.REASONING_KEYS names the knobs this server drives, with a test asserting
  it stays exactly equal to what reasoning_kwargs can emit -- so a new template
  knob can't be added without also taking it away from clients.
- Two strings that still described a menu of models, from before the block held
  a single entry.

Verified against the live MLX server: with the dashboard on xhigh, five request
shapes (nothing, enable_thinking: false, effort low top-level, effort low in
kwargs, and the off-scale "turbo" that used to 404) all answer identically, and
the reply tracks the dashboard alone as it moves off / low / xhigh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Neil Bantoc 2026-11-03 15:01:26 -08:00
parent e48517b1cf
commit e24c0b7712
10 changed files with 134 additions and 151 deletions

View file

@ -200,6 +200,11 @@ def reasoning_options(entry, choice, controls):
return opts if len(opts) > 1 else []
# The chat-template knobs this server drives. A client's own values for these are dropped
# on the way through the proxy: the setting is the dashboard's, not the client's.
REASONING_KEYS = ("enable_thinking", "reasoning_effort")
def reasoning_kwargs(value, entry, controls):
"""chat_template_kwargs for a setting, or {} for "default"/anything unsupported."""
if not value or value == DEFAULT or not entry.get("reasoning"):
@ -211,25 +216,3 @@ def reasoning_kwargs(value, entry, controls):
return {"reasoning_effort": value}
return {}
# Effort levels in order, for mapping a level a model lacks onto the nearest it has.
EFFORT_SCALE = ["none", "minimal", "low", "medium", "high", "xhigh", "max"]
def effort_levels(entry, controls):
"""The effort levels this model's template accepts, or () if it takes none."""
levels = (entry.get("effort") or {}).get("levels") or []
return tuple(levels) if entry.get("reasoning") and controls.get("effort") else ()
def nearest_effort(value, levels):
"""The level in `levels` closest to `value` on EFFORT_SCALE; on a tie, the higher one
(asking for "high" between medium and xhigh means wanting more, not less). None when
either is off the scale."""
if value not in EFFORT_SCALE:
return None
want = EFFORT_SCALE.index(value)
known = [l for l in levels if l in EFFORT_SCALE]
if not known:
return None
return min(known, key=lambda l: (abs(EFFORT_SCALE.index(l) - want), -EFFORT_SCALE.index(l)))