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

@ -15,7 +15,7 @@ import sys
import threading
import time
from .. import hfcache, paths, plan
from .. import hfcache, paths
from . import proxy
VENV = paths.DATA / "venv-mlx"
@ -104,8 +104,7 @@ def run_server(cfg, entry, choice, args):
controls = hfcache.template_controls(choice["repo"])
srv = proxy.listen(port, proxy.make_handler(
inner, entry["name"], choice.get("est_context", entry["context"]), paths.api_key(), stats,
aliases=(choice.get("repo"),), reasoning=proxy.reasoning_setting(entry, controls),
effort_levels=plan.effort_levels(entry, controls)))
aliases=(choice.get("repo"),), reasoning=proxy.reasoning_setting(entry, controls)))
proxy.kill_stale(inner, VENV, "mlx_lm")
exe = str(VENV / "bin/mlx_lm.server")