From e48517b1cfa337e75323fff8ac7cc73a4c516b27 Mon Sep 17 00:00:00 2001 From: Neil Bantoc Date: Tue, 3 Nov 2026 15:01:12 -0800 Subject: [PATCH] Setup: keep the dashboard's reasoning setting across an update cmd_setup rebuilds config.json from the plan, and the reasoning setting isn't part of the plan -- the dashboard writes it into the same file. So every `llmhost update` (setup --yes under the hood) silently put every model back to "Model default", losing a setting the user had chosen in the UI. Carry it over, minus models that no longer fit. The helper exists so the reason is on the record rather than implied by a dict literal; its tests cover the empty and no-longer-fits cases that must not write the key at all. Co-Authored-By: Claude Opus 5 (1M context) --- llmhost/cli.py | 10 ++++++++++ tests/test_reasoning.py | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/llmhost/cli.py b/llmhost/cli.py index afbcdda..99f7036 100644 --- a/llmhost/cli.py +++ b/llmhost/cli.py @@ -111,6 +111,15 @@ def cmd_plan(a): say("\nNothing fits. " + (p.get("reason") or "")) +def carried_settings(old, names): + """Settings setup must not reset. The plan is setup's to rebuild, but the reasoning + setting belongs to the dashboard, which writes it into the same file -- without this an + `llmhost update` would quietly put every model back to "Model default". Models that no + longer fit lose their setting along with their plan.""" + kept = {k: v for k, v in (old.get("reasoning") or {}).items() if k in names} + return {"reasoning": kept} if kept else {} + + def cmd_setup(a): info = hw.detect() cat = paths.load_catalog() @@ -169,6 +178,7 @@ def cmd_setup(a): "models": p["models"], "excluded": p["excluded"], "active": active, p["backend"]: {**old.get(p["backend"], {}), **backend_info}, } + cfg.update(carried_settings(old, names)) paths.save_config(cfg) key = paths.api_key(create=True) diff --git a/tests/test_reasoning.py b/tests/test_reasoning.py index 6e17ddd..4ed7cba 100644 --- a/tests/test_reasoning.py +++ b/tests/test_reasoning.py @@ -88,4 +88,23 @@ check("no server default -> client kwargs preserved", check("a non-dict from the client isn't merged into", inject({"reasoning_effort": "low"}, {"chat_template_kwargs": "nope"}) == {"reasoning_effort": "low"}) +print("\n5. the setting survives a setup re-run (`llmhost update`)") +from llmhost import cli +NAMES = ["qwen3.8-27b", "ornith-1.5-9b"] +check("a set choice is carried over", + cli.carried_settings({"reasoning": {"qwen3.8-27b": "xhigh"}}, NAMES) + == {"reasoning": {"qwen3.8-27b": "xhigh"}}) +check("every model's choice is kept, not just the active one", + cli.carried_settings({"reasoning": {"qwen3.8-27b": "xhigh", "ornith-1.5-9b": "off"}}, NAMES) + == {"reasoning": {"qwen3.8-27b": "xhigh", "ornith-1.5-9b": "off"}}) +check("a model that no longer fits is dropped", + cli.carried_settings({"reasoning": {"qwen3.8-27b": "xhigh", "gone-70b": "low"}}, NAMES) + == {"reasoning": {"qwen3.8-27b": "xhigh"}}) +check("nothing set -> no key written", cli.carried_settings({}, NAMES) == {}) +check("empty setting -> no key written", cli.carried_settings({"reasoning": {}}, NAMES) == {}) +check("no model still fits -> no key written", + cli.carried_settings({"reasoning": {"gone-70b": "low"}}, NAMES) == {}) +check("setup's own keys are not touched", + set(cli.carried_settings({"reasoning": {"qwen3.8-27b": "low"}}, NAMES)) == {"reasoning"}) + check.done(ROOT)