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

@ -309,18 +309,22 @@ check("model is <provider>/<an entry in the block>",
snip["model"].partition("/")[0] == prov_id and snip["model"].partition("/")[2] in block["models"],
(snip["model"], list(block["models"])))
check.section("24. the block offers only the effort levels the loaded model accepts")
check("qwen3.8: hide high, add xhigh",
opencode.effort_variants(("low", "medium", "xhigh")) == {"high": {"disabled": True},
"xhigh": {"reasoningEffort": "xhigh"}},
opencode.effort_variants(("low", "medium", "xhigh")))
check("no levels: hide opencode's whole menu",
opencode.effort_variants(()) == {l: {"disabled": True} for l in ("low", "medium", "high")})
check.section("24. the block never offers a reasoning chooser of its own")
check("opencode's whole menu is switched off",
opencode.effort_variants() == {l: {"disabled": True} for l in ("low", "medium", "high")},
opencode.effort_variants())
q = opencode.provider_block(dict(CFG, active="qwen3.8-27b"), "popos.local", "k", "popos.local")
ent = q["models"]["default"]
check("qwen3.8 block (not downloaded: catalog levels)",
ent.get("variants") == {"high": {"disabled": True}, "xhigh": {"reasoningEffort": "xhigh"}}, ent)
check("a reasoning model is marked as one (so thinking blocks render)", ent.get("reasoning") is True, ent)
check("but every effort level is disabled",
ent.get("variants") == {l: {"disabled": True} for l in ("low", "medium", "high")}, ent)
check("no variant carries a reasoningEffort to send",
not any("reasoningEffort" in v for v in ent["variants"].values()), ent["variants"])
check("the model levels from the catalog are not offered either",
not ({"xhigh"} & set(ent["variants"])), ent["variants"])
nr = opencode.provider_block(dict(CFG, active="qwen3-coder"), "popos.local", "k", "popos.local")
check("a non-reasoning model gets no variants", "variants" not in nr["models"]["default"], nr["models"]["default"])
check("one entry only, named for the alias, so the client can't pick a model either",
list(q["models"]) == [plan.SERVED_ALIAS], list(q["models"]))
check.done(ROOT)