The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(local-models): quickstart prices the model after installing the engine
teknium12e62565b51bf
diff --git a/hermes_cli/web_routers/local_models.py b/hermes_cli/web_routers/local_models.pyindex 8a43a4b2432..cf380ce88ea 100644--- a/hermes_cli/web_routers/local_models.py+++ b/hermes_cli/web_routers/local_models.py@@ -775,6 +775,17 @@ def _quickstart_target(body: QuickstartBody, budget):"no catalog model fits this machine — open Local Models to browse for a smaller build"))+def _repriced_quickstart(job: Dict[str, Any], body: QuickstartBody, variant):+ """Re-pick once the engine is installed, before any bytes are committed: a Vulkan/HIP GPU's+ type and size come from that engine's own device probe, so the preflight price was a guess."""+ entry, picked = _quickstart_target(body, hardware.probe_budget(planning=True))+ if picked.model_id != variant.model_id:+ with _JOBS_LOCK:+ job.update(target=entry.display_name, model_id=entry.id)+ plan = _download_plan(entry, picked)+ return entry, picked, plan if any(not dest.is_file() for _, dest, _ in plan) else []++@router.post("/api/local-models/quickstart")def local_models_quickstart(body: QuickstartBody, profile: Optional[str] = None):"""One job: install the runtime (if missing), download this machine's build of the recommended model (if@@ -793,9 +804,11 @@ def local_models_quickstart(body: QuickstartBody, profile: Optional[str] = None)raise HTTPException(status_code=409, detail="Setup is already running")job = _job("quickstart", entry.display_name, model_id=entry.id)def _run():+ nonlocal entry, variant, download_planif need_runtime and binaries.installed_engine(backend) is None:_install_engine_job(job, backend)- if need_download:+ entry, variant, download_plan = _repriced_quickstart(job, body, variant)+ if download_plan:# Each phase has its own complete download plan. Resume within a# phase retains counters until PM reports the durable bytes.if job["phase"] != "downloading":diff --git a/tests/hermes_cli/test_local_quickstart.py b/tests/hermes_cli/test_local_quickstart.pyindex 18436aac068..50fbdc7e88e 100644--- a/tests/hermes_cli/test_local_quickstart.py+++ b/tests/hermes_cli/test_local_quickstart.py@@ -290,3 +290,41 @@ def test_assign_default_reaches_model_assignment(monkeypatch):lambda *a, **k: seen.append(a))lm._assign_default({}, "some-model")assert seen == [("main", "llamacpp", "some-model", "", "", "")]+++def test_quickstart_prices_after_installing_the_engine(client, monkeypatch):+ """A Vulkan/HIP card's size comes from the installed engine's own device probe, so the model the+ job downloads and makes default is the one priced AFTER the install, not the preflight guess."""+ import hermes_cli.web_routers.local_models as lm+ from hermes_cli.local_runtime.catalog import CATALOG, VariantChoice+ from hermes_cli.local_runtime.estimator import HardwareBudget++ gib = 1 << 30+ as_ram = HardwareBudget(usable_vram_bytes=50 * gib, total_device_bytes=50 * gib,+ ram_available_bytes=128 * gib, uma=True)+ as_card = HardwareBudget(usable_vram_bytes=22 * gib, total_device_bytes=24 * gib,+ ram_available_bytes=128 * gib, uma=False)+ guess, fit = CATALOG[0], CATALOG[1]+ installed: list[str] = []+ downloaded: list[str] = []+ assigned: list[str] = []++ monkeypatch.setattr(lm.hardware, "probe_budget", lambda **kw: as_card if installed else as_ram)+ monkeypatch.setattr(lm.catalog, "recommended_entry",+ lambda budget, entries=None, backend="auto": (guess if budget is as_ram else fit, "best-fits"))+ monkeypatch.setattr(lm.catalog, "select_variant", lambda entry, budget: VariantChoice(+ variant=entry.variants[0], zero_spill=True, reason_key="best-fits"))+ monkeypatch.setattr(lm, "_engine_too_old", lambda min_engine: False)+ monkeypatch.setattr(lm, "_runtime_target", lambda backend=None: ("b1", "vulkan"))+ monkeypatch.setattr(lm.binaries, "installed_engine", lambda *a, **k: None)+ monkeypatch.setattr(lm.binaries, "ensure_engine", lambda backend, **kw: installed.append(backend))+ monkeypatch.setattr(lm, "_run_download_plan", lambda job, plan, label: downloaded.append(label))+ monkeypatch.setattr(lm, "_ensure_server", lambda *a, **k: None)+ monkeypatch.setattr(lm, "_assign_default", lambda job, model_id: assigned.append(model_id))++ r = client.post("/api/local-models/quickstart", json={})+ assert r.status_code == 200+ job = _wait_job(client, r.json()["job_id"])+ assert job["status"] == "done", job["error"]+ assert installed == ["vulkan"]+ assert (job["model_id"], downloaded, assigned) == (fit.id, [fit.display_name], [fit.variants[0].model_id])