These grew one bug at a time in a scratch directory and were about to be thrown
away, having caught four real regressions between them. Move them in as they
are -- plain scripts, stdlib only, no test dependency -- behind a shared harness
and `python3 tests/run.py`.
The harness exists mostly for its guard. A suite testing the purge path once
sandboxed LLMHOST_CONFIG but not LLMHOST_HOME and deleted a live install's data
directory; BIN_DIR and SHIM have no env override at all, coming straight off
Path.home(). So the harness repoints those into the sandbox and then asserts
that every path llmhost could write or delete is inside it, aborting the run if
not -- verified by pointing it at a real path and watching it refuse.
The model plan the opencode suite needs is now a fixture rather than a file read
out of someone's home directory; it carries no key (the key lives in its own
file) and its machine-specific fields are pinned.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reasoning effort isn't a backend flag -- vLLM's --reasoning-parser only parses
the output. It's a chat-template kwarg read per request, and the models differ:
Qwen3.8 27B's template takes enable_thinking plus reasoning_effort in
('low','medium','xhigh') and raises on anything else, while Ornith 1.5 9B takes
only enable_thinking. Note 'xhigh', not OpenAI's 'high'.
So the chooser is built from what the loaded model's own template actually reads
(hfcache.template_controls), with the level names from the catalog, which is the
part that can't be inferred -- a level the template doesn't know would make it
raise, so an undeclared or unreadable one is never offered or sent.
The proxy injects the setting into chat completions, with a key the client set
itself always winning, the same precedence mlx_lm gives its own
--chat-template-kwargs. Reading it from config per request (mtime-cached) means
the dashboard changes it with no restart, so the model stays loaded -- the
startup flag would have cost a full reload per change.
vLLM gets no control: llm-host runs it without a proxy, so there is nothing in
the path to inject the kwarg. The panel hides itself rather than pretend.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three gaps, all of them things the dashboard drew but never filled.
KV cache was never reported on MLX: /llmhost/metrics had no "kv" key at all,
so the tile and chart sat empty. mlx_lm has no endpoint for it, but it logs
"Prompt Cache: N sequences, X GB" (decimal GB, n_bytes/1e9) and that stream
already passes through _pump_output, so pick it out there and report a fraction
of --prompt-cache-bytes -- the same shape vLLM's kv already has, so the sampler
needs no backend special-casing. Peak is kept alongside the current value.
GPU temperature and power are root-only on macOS (powermetrics), so hw.live_stats
has always returned None for them on Apple. Two permanently blank charts is worse
than none: hide them and say why when the hardware doesn't report them.
Add a completed-request table above the server log: when each request finished,
its duration, time to first token, prompt and generated tokens, the rate for each
phase, and peak KV during the run. Rates are split at the first token -- prompt
tokens over TTFT, generated tokens over what's left -- since a single rate over
the whole duration blurs prefill into generation. The proxy keeps the last 50 runs;
peak KV is joined in by the sampler, which is the only side that samples KV on a
timer.
Also: close the upstream connection explicitly when a client hangs up mid-answer
rather than leaving it to GC, log that in one line, and collapse mlx_lm's
resulting BrokenPipeError traceback in the log view. Any other traceback is left
verbatim.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The MLX proxy rewrote every request's "model" to the preloaded one, so asking
for a model the server wasn't running returned another model's output wearing
the requested name -- silently. The rewrite itself has to stay (mlx_lm would
otherwise try to load a model matching the name), so validate first: a name
that is neither the served name nor its repo id gets 404 model_not_found,
naming what is loaded and how to switch. An unstated name still means "the
loaded one", and the key is still checked before the model.
opencode's /models hid the same trap twice over. Label models
`<title> · <slug> (<where>)` so the list is searchable by the id used
everywhere else -- titles alone had dropped the slug -- and mark the loaded
one `(Local, loaded)`, refreshed by both switch paths (CLI and dashboard)
through a new opencode.sync(), which only ever refreshes a block that is
already there.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
opencode caches a provider's key in ~/.local/share/opencode/auth.json and that
copy wins over opencode.json: with a stale entry it fails auth without sending
a request at all and asks for the key interactively. Verified by A/B on a live
install -- correct entry works, wrong entry never reaches the server, absent
entry works and reads the key file.
llm-host mints a fresh key whenever the config dir is purged, so the cached
copy went stale on every reinstall. configure() now drops the entry for its own
provider, leaving the {file:...} reference authoritative; it tracks the key file
and cannot go stale. remove() takes the cached key with the provider. Other
providers' credentials are never touched, and an unreadable store is left alone
rather than repaired.
Add `uninstall --purge --keep-key` so the key survives a purge and a reinstall
reuses it -- clients elsewhere then keep working. Warn about the new key when
it doesn't. Factor the purge into purge() so it can be tested without touching
a real install.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
/models showed "qwen3.8-27b (Local)" where the catalog already has a name
meant for reading: "Qwen3.8 27B". The dict key stays the slug -- that is the
model id the API answers to -- so only the display name changes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The local and remote setup paths already used distinct provider ids, so one
opencode config can point at a local server and any number of remote ones.
Name them after the machine they reach so they're tellable apart in /models.
Decide which block is *this* machine's by the key-file reference it carries
rather than by its name, so:
- a provider renamed by hand is still recognised and updated in place
instead of a second one being added next to it;
- a remote provider sitting under the `llmhost` id is no longer silently
overwritten with a localhost baseURL (setup takes `llmhost-local` and
says so) -- the one-shot .before-llmhost backup could not recover it;
- uninstall removes only the local provider, never `llmhost-*` blocks for
servers that are still running, and never providers it didn't create.
Add `llmhost opencode-remove` for the case the servers can't handle for each
other: uninstalling on a server can't reach the clients pointing at it. Wire
uninstall to it, repointing opencode's default model at a surviving llm-host
provider and dropping `model` only when none is left.
Also split config read/write out of configure() and report `unparsable`: a
syntactically broken opencode.json used to raise ValueError mid-setup.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The proxy only added a request's prompt tokens from the final usage chunk, so a
long prefill showed as a flat prompt rate and then one spike (prompt size over a
2 s sample), and requests the client abandoned mid-prefill were never counted.
mlx_lm.server already streams ": keepalive <done>/<total>" after each prefill
step; count those as they pass through, and top up from the usage chunk. Also
leave out prompt-cache hits (cached_tokens), which take no processing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
vLLM: from the vllm:time_to_first_token_seconds histogram. MLX: the proxy
times streamed requests from arrival to the first generated token. Each
chart sample is the average over requests that got their first token in
that 2 s window; idle samples are gaps, and isolated samples now draw as
dots in every chart.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
- mlx_lm.server kept up to 10 conversations' KV caches with no byte
limit and prefilled 8 prompts at once, which ran a 16 GB Mac out of
GPU memory. The plan now gives the live request half the free memory
(at least 32k tokens), caps --prompt-cache-bytes to the rest, and on
small machines prefills one prompt at a time.
- When its generation thread dies, mlx_lm.server keeps running but fails
every request. The proxy now restarts it.
- llmhost watch: one live line with download progress (bytes, speed,
time left), then loading, until the model answers. Setup and switch
point at it instead of llmhost logs -f.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
The TIME_WAIT fix only applied on Linux, so a reinstall on a Mac right
after uninstall still saw 1134 as busy (the old dashboard's connections
were closing) and moved the API to 1136. Now a port is busy only if
something accepts connections on it or a SO_REUSEADDR bind fails, on
both platforms. Uninstall also waits for the services to release their
ports before returning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
New installs use 11340 instead of 8080, which is often taken by other
dev servers. Existing installs keep their saved port.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
Binding without SO_REUSEADDR fails while connections to a just-stopped
server linger in TIME_WAIT, so setup moved to the next port even though
nothing was listening. Servers bind with SO_REUSEADDR, so check the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
The old hint pointed at `hf`, which lived in the venv uninstall had just
deleted. Uninstall now lists llm-host's catalog models in the cache with
their sizes and asks (default no); --models deletes without asking. It
runs `uv tool run --from huggingface_hub hf cache rm`, which also frees
blobs in the shared hub/blobs directory, and prints that exact command
when models are kept. Models outside the catalog are never touched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
After confirming, setup stops the old services and waits up to 30s for
their ports to free, with no output. Show a spinner with elapsed seconds
immediately (a plain line when not on a terminal), ending in a check mark.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
Appends an export to the profile for the user's shell (zsh: .zshrc,
bash: .bash_profile on macOS / .bashrc on Linux, fish: config.fish),
once, and tells the user to open a new terminal at the end of setup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
After setup, if opencode is missing, offer to install it with its
official installer; then add an `llmhost` provider pointing at
http://localhost:<api port>/v1 that reads llm-host's key file directly.
Other providers and the default model are kept, the original config is
backed up once, trailing commas are tolerated, and a config with
comments is left untouched (the block is printed instead). Re-runs and
`llmhost update` keep the provider's port and models in sync.
New: `llmhost opencode-setup`, and setup flags --opencode / --no-opencode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
Listed last so larger machines keep their current default. Builds: BF16,
NVFP4, AWQ and MLX 8/6/4-bit. Its KV cost (17.6 KiB/token) is estimated
from config.json (8 full-attention layers x 4 KV heads x 256 dims, fp8)
plus the ~10% margin the measured 35B/122B numbers showed over the same
formula; it hasn't been measured on hardware yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
`llmhost update` stopped the services and checked the ports before the
old processes had released them (launchctl bootout returns early), so
the API hopped to the next free port and broke configured clients.
Setup now waits for our own ports to close, and treats saved ports as
pinned: if another program holds one it errors instead of moving. Only
a first install auto-picks a free port.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
Streamed responses only carry usage when the client asks for it, so the
prompt processing chart stayed at zero on Macs. The proxy now requests
the usage chunk itself and strips it from responses to clients that
didn't ask, forwarding the stream one whole event at a time.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
Sits between generation tok/s and KV cache in a three-chart row
(stacks on narrow screens), with the same hover readout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
mlx_lm.server's /health is OK as soon as its thread starts, so the
dashboard showed Ready while the model was still downloading. The proxy
now sends a 1-token probe and answers /health with 503 until it succeeds.
Also drop health-check, dashboard-poll and per-file HF request lines from
the MLX log while keeping download progress bars.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
On a Mac with port 8000 already taken, the proxy failed to bind after
mlx_lm.server had started, leaving an orphan each time launchd retried.
- setup now stops our own services, then moves the API/dashboard to the
next free ports (or errors if a port was given explicitly)
- the MLX service binds its port before starting mlx_lm.server, always
stops the child on exit, and cleans up leftovers from earlier crashes
- drop the nonexistent huggingface_hub[cli] extra
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
nvcc resolves its toolkit from its real path, so a symlink made it look
for lib64 inside a single pip wheel and fail to link cudart_static.
Also make `llmhost start` start the dashboard after `setup --no-start`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca
Detects the GPU (NVIDIA on Linux, Apple Silicon on macOS), picks the
catalog models and builds that fit, installs vLLM or MLX without sudo,
and runs the model server plus a web dashboard as user services.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca