Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ADR 0082: A llama.cpp server wisp starts for the models it knows

Date: 2026-10-27. Status: accepted by the operator on 2026-10-29, after the probe below; built for 0.33.0 (decisions 1 to 8; of decision 2, adding a path, not a download). Amended by ADR 0084, decision 8: from Wisp.app, a job left by the formula’s LaunchAgent file whose wisp is gone is replaced by the app’s Login Item. Agreed by the operator on 2026-10-27: wisp should be able to start llama.cpp’s llama-server for the models it knows about, as a release of its own after 0.32.0. Builds on ADR 0058, which talks to a server someone else started.

Context

Of wisp’s local runtimes, llama.cpp is the one the person has to keep running by hand. Ollama loads and unloads its own models behind one daemon; MLX and Core AI run inside wisp (ADR 0052); LM Studio has its own app. For llamacpp:<name> wisp only connects to llamacpp.baseURL and, when nothing answers, says no llama.cpp server at …; start one with llama-server -m <model.gguf>, or set llamacpp.baseURL (ADR 0058, backends.md).

That matters because llama.cpp is where the fastest accurate model for tool work runs: Ternary-Bonsai-2-9B-Q2_0 was as accurate as granite4.1:8b on the tools on 2026-10-17 and two to four times faster at diff summaries and as a classifier (measurements.md), and its Q2_0 ternary format is llama.cpp’s.

What llama-server offers, from llama-server --help of the Homebrew build on this Mac on 2026-10-27 (version 0.7.0, build 11669):

OptionWhat it does
--models-dir PATHRouter mode: one server for every model in a folder, each loaded when first asked for
--models-max NAt most N models loaded at once (default 4; 0 for no limit)
--models-autoload, --no-models-autoloadWhether a request loads a model (default on)
--models-preset PATHAn INI file of per-model settings for the router
--sleep-idle-seconds NSleep after N seconds idle (default off)
--host, --portDefault 127.0.0.1 and 9931; wisp’s llamacpp.baseURL defaults to port 8080
--api-key-file FNAMEKeys read from a file rather than the command line

A router already reports a status per model in /v1/models, which wisp reads (ADR 0058). So one server can serve every model wisp knows about, without wisp handing out ports or choosing which model to keep in memory.

The probe of 2026-10-29 (measurements.md, “A llama.cpp router for wisp’s models”), with the Homebrew llama-server 0.7.0 and the three Bonsai 2 models linked into a folder, found:

QuestionResult
Does a router serve linked models under their names?Yes: links are followed, each model is named after its file, and /v1/models lists each unloaded until asked for
Does --api-key-file hold?Yes: a request without the key gets 401
Does a ternary model behave the same under the router?Yes: wisp’s five tool prompts on the 9B through the router and through -m, 5/5 each, the same answers, at 1.6 to 6.3 s and 1.5 to 5.0 s
How long is a load?8.5 s for the 9B’s first load from disk, about 2 s again later, 1.4 to 2.4 s to switch models under --models-max 1; 0.2 to 0.5 s a request once loaded
How much memory?11.4 GB for the 9B at llama.cpp’s defaults (a 262,144-token context, 4 slots); 3.8 GB at --ctx-size 32768 --parallel 1, which the router passes on to each model
What does idle sleep save?After 20 s idle under --sleep-idle-seconds 20 the 9B’s process fell to 217 MB; the next request woke it in 0.74 s
Does stopping the router stop its models?Yes

The same day Llama.app (llama.app 0.46.1, team V89L745MNN) was found on this Mac already running a router of its own, on port 9931, with one model at a time, idle sleep after 300 s, models from ~/.config/llama/models.user.ini, no key, and CORS open to every origin. wisp, at llamacpp.baseURL’s default port 8080, did not use it.

Starting a server is new for wisp in three ways. It runs a program wisp did not build, outside wisp’s sandbox; it keeps a process alive after the command that wanted it has ended; and it opens a port any process on the Mac can reach.

Decision

Agreed by the operator on 2026-10-29:

  1. One router, not a server a model. wisp’s server is llama-server --models-dir <folder>, and a model is loaded by the router when a request names it, within --models-max.
  2. The models it knows. The folder is ~/Library/Application Support/Wisp/llamacpp/models, holding links to GGUF files the person adds with wisp models (a path, or a download through the models flow that already asks before pulling). wisp does not scan the disk for GGUF files. It is the first of wisp’s state in Application Support, the place the operator prefers for what other agents should not reach, ahead of the protection track’s decision for the rest.
  3. Whose server: llamacpp.server, one of three:
    • off, the default: wisp connects to llamacpp.baseURL as today, and starts nothing;
    • wisp: wisp’s own router (decisions 4 to 7);
    • llama-app: wisp uses Llama.app’s router, finding its port, and starts nothing; the person adds models in Llama.app. Its server has no key and answers any origin, which wisp doctor says.
  4. A LaunchAgent keeps wisp’s router running, with idle sleep: Wisp.app registers it with SMAppService, so it shows in Login Items and the person can turn it off there, and a Homebrew install writes the agent’s file itself. launchd restarts and logs it. The agent’s file inside a signed Wisp.app is fixed, so it cannot carry the person’s settings: it runs a hidden subcommand, wisp llamacpp serve, left out of --help, which reads the configuration, checks the binary, and starts llama-server in its place. Idle sleep takes a loaded model to about 200 MB and wakes it in under a second, so a process that stays costs little.
  5. Which binary. The server is a path the person names or approves once (llamacpp.serverPath), recorded with its digest and checked before each start, as ADR 0080 proposes for skills; not the first llama-server on PATH. The proposal of 2026-10-27 named this setting llamacpp.server; amended on 2026-10-29 to llamacpp.serverPath, since llamacpp.server is now the choice of whose server (decision 3). A changed digest, as every brew upgrade llama.cpp makes, is not started: wisp asks the person to approve the new one at the same path, and wisp doctor names the change. Starting it and approving it are audited.
  6. Access. It listens on 127.0.0.1 only, with a key wisp generates, kept in a file only the person can read and passed by --api-key-file, and never logged or shown (as llamacpp.apiKey is today).
  7. Memory, set in configuration, each setting explained by wisp config and wisp doctor with what it costs: a 65,536-token context, 1 slot, up to 2 models loaded at once, and sleep after 600 s idle by default (the 9B took about 5 GB at that context with one slot, measured with the build on 2026-10-30; 3.8 GB at 32,768). The operator chose these over 32,768 tokens and one model, and over llama.cpp’s own defaults (11.4 GB for the 9B alone), as long as each is configurable and its effect is plain to the person. wisp doctor reports the server, its models, and what is loaded.
  8. Off by default: llamacpp.server is off; without a change wisp behaves as today.

Consequences

  • llamacpp:<name> works without the person starting a server, and the error that tells them to start one is replaced by starting it, or by saying why wisp would not (no approved binary, the setting off).
  • wisp gains a long-lived process of its own beyond wisp mcp and the notifier, with its start, stop, and logs to be documented in backends.md and wisp.md, and its events in logging.md.
  • The binary’s digest and the key file sit in ~/.wisp, under the same protection, or lack of it, as the rest; the protection track on the roadmap decides whether they move.
  • Ollama and LM Studio are unchanged: they manage their own processes.
  • The probe settled what the decisions waited on: load times of seconds, and a ternary model the same under the router as under -m.
  • Llama.app’s router, open to any local process and web page, is the person’s choice under llama-app; wisp says so rather than refusing it.
  • Amended on 2026-10-30, with decision 5 built: the approval (path as given, real path, SHA-256, when) is kept in ~/Library/Application Support/Wisp/llamacpp/server.json, owner only, not in ~/.wisp, and config.json holds only llamacpp.serverPath, so a path written there by hand is not approved. The digest covers the llama-server executable only: the libraries it loads from its install (Homebrew’s Cellar: libllama, libggml*) are not checked, so a change to them alone is not seen. A known limit, not solved here.
  • Amended on 2026-10-30, with decisions 1, 4, 6, and 7 built:
    • Names. The settings are llamacpp.serverContextLength (65,536), llamacpp.serverSlots (1), llamacpp.serverModelsLoaded (2), llamacpp.serverIdleSeconds (600; 0 never sleeps), and llamacpp.serverPort, beside llamacpp.serverPath: llamacpp.server holds a word, so they cannot sit under it, and the server prefix keeps them apart from a context length a request asks for. The agent’s label is com.pidster.wisp.llamacpp, after the notifier’s.
    • Port. 8933 by default: not 8080, where off looks for a server the person starts, nor 9931, llama-server’s default and Llama.app’s, nor Ollama’s or LM Studio’s, and not assigned in /etc/services. Under wisp, llamacpp.baseURL is not used: wisp asks http://127.0.0.1:<llamacpp.serverPort>.
    • No web UI. The router is started with --no-ui (llama-server 0.7.0’s name; --no-webui is its deprecated alias): wisp needs only the API, and a smaller surface on the port fits decision 6. Probed on 2026-10-30: with it / answers 404 instead of 415, the API answers as before with the key, and the router passes it on to each model’s process, which logs “The UI is disabled”.
    • Key. 32 random bytes as 64 hex digits in ~/Library/Application Support/Wisp/llamacpp/api-key (folder 0700, file 0600, made once at the first start, with O_EXCL, and reused). Under wisp it is the only key wisp sends: llamacpp.apiKey and WISP_LLAMACPP_API_KEY are not used, since the server answers no other, and a key that wins over the file could only ever be refused.
    • KeepAlive. { Crashed: true } with RunAtLoad and a ThrottleInterval of 30 s, rather than SuccessfulExit: false: wisp llamacpp serve refusing to start (binary changed, setting off) exits 78, and llama-server failing to bind its port exits 1; restarting on every non-zero exit would loop every 30 s with the same refusal. A crash is started again; anything else waits for the person, whose next approval or setting restarts it.
    • KeepAlive, amended the same day after the trial on this Mac. { SuccessfulExit: false }, and a refusal to start exits 0. With Crashed, launchd started the router again after SIGABRT but not after SIGKILL, the signal macOS frees memory with, which would have left the server down until the person turned it off and on. A killed model process heals itself: the router survived a SIGKILL of the 9B’s process and loaded it again on the next request, in 5.3 s. Now a crash or a kill of the router is started again, a refusal is not, and llama-server failing to bind its port is retried every 30 s, logged, until the port is free.
    • A stale Login Item. In the same trial, a LaunchAgent file of the same label, loaded by launchctl and since removed, left SMAppService reporting the app’s agent enabled with no job in launchd, so the restart wisp sent in place of registering failed (“Could not find service”). Registering now restarts only a job launchd has, and otherwise registers.
    • Restart on change. Setting llamacpp.server wisp registers (or, registered, starts it again); setting it otherwise, unsetting it, or wisp uninstall from Wisp.app unregisters it. A change to a server… setting, an approval of the binary, and a model added or removed restart it with launchctl kickstart -k when registered: the router reads its models folder only when it starts (probed on 2026-10-30: a link added while it ran was not listed). All are said before they are done and audited as llamacpp.agent. Every llamacpp.server… setting is the person’s: the default policy refuses wisp config set|unset llamacpp.server… to the model, and chat’s /config sends the person to a terminal.
    • Registration. From Wisp.app, SMAppService.agent(plistName:) with the app’s own agent file; it reads the main bundle, so a wisp started through a link (whose main bundle is the link’s folder) asks the app’s own wisp (wisp llamacpp agent register|unregister|status). Otherwise a file in ~/Library/LaunchAgents, naming Homebrew’s opt path for a Homebrew install, loaded with launchctl bootstrap gui/<uid>. A home other than the person’s, or WISP_LLAMACPP_AGENT=off, registers nothing. launchd keeps no output: wisp llamacpp serve sends its own and llama-server’s to ~/Library/Logs/Wisp/llamacpp.log.
    • Signals. wisp llamacpp serve runs on a thread of Swift’s concurrency pool, which blocks signals, and a program keeps its caller’s signal mask across execve: the first build’s llama-server, and the model process it started, ignored SIGTERM. Every signal is now unblocked and set to its default before execve; the router and its model then stopped within a second of SIGTERM (2026-10-30).
    • Not tried for real. Registering with SMAppService and launchctl was built behind a protocol and tested with fakes; the measurement ran the server in the foreground from a scratch home, where nothing is registered. Superseded the same day by the trial on this Mac (the two bullets above on KeepAlive and a stale Login Item): the agent ran for real under launchd, with a file in ~/Library/LaunchAgents and with Wisp.app’s Login Item, whose stale state that trial found, and the router it kept served the comparison of 2026-10-30 (measurements.md). The automated tests still use fakes.

Amended 2026-10-30, at the docs sweep for 0.33.0: two statements above are overtaken by what was built and measured. Decision 4’s “about 200 MB” asleep was 217 MB on 2026-10-29 at a 32,768-token context and 387 MB on 2026-10-30 at the default 65,536 (measurements.md). The consequence that the binary’s digest and the key file sit in ~/.wisp is overtaken by stages 3 and 4: both are in ~/Library/Application Support/Wisp/llamacpp, with the models’ links (decision 2).

Amended 2026-10-30, for 0.33.1: the Login Item after an update. After wisp update replaced Wisp.app (0.32.0 to 0.33.0) on this Mac, and after a trial app of the same bundle identifier had been built in a temporary folder, registered, unregistered, and deleted, registering the agent left SMAppService reporting it registered while launchd refused to start it (last exit code 78, EX_CONFIG, state “spawn scheduled”, a launch constraint with an empty list of code hashes), and nothing reached the log. wisp llamacpp agent unregister then found SMAppService reporting the agent not found and did nothing, while launchd still held the job (type Submitted, managed by com.apple.xpc.ServiceManagement). lsregister -f /Applications/Wisp.app, then unregistering (which now removed the job) and registering, mended it. The cause is not proven; a record in Launch Services of a copy since deleted or replaced is the leading guess. Three changes follow. wisp update, and the Finder dialog’s update, register the new app with Launch Services and, when the agent is registered, waiting for approval, or held by launchd, unregister and register it again through the new app’s own wisp; a failure there is a warning, never a failed update. Unregistering removes a job launchd holds for the label when SMAppService reports none (launchctl bootout), and registering removes one first. The agent’s state gains “held by launchd” and “refused by launchd” (a last exit of 78 with nothing running; wisp llamacpp serve never exits 78), which wisp doctor reports with the mend, the hidden wisp llamacpp agent repair (Launch Services, unregister, register). Registering does not repair a refusal by itself: a heuristic acting on launchd’s output was judged less safe than naming the command. Tested with fakes; not yet tried for real.

Amended 2026-10-30, for 0.33.1: a job another install registered. On this Mac the router ran as Wisp.app’s Login Item (launchd’s gui/501/com.pidster.wisp.llamacpp, type Submitted, managed_by = com.apple.xpc.ServiceManagement, path = (submitted by smd…)) and answered on 127.0.0.1:8933 with wisp’s key, while a wisp outside the app (the release’s staged binary, a build) chose a file in ~/Library/LaunchAgents, found none, and reported the agent “not registered”, so wisp doctor failed and scripts/release stopped. The agent’s state is now read from launchd as well as from this install’s means: a job of the label that this install did not register is “registered by” its holder, read from launchctl print (managed_by SMAppService is Wisp.app’s Login Item; a path naming another file is that LaunchAgent file; neither is another install), “not by this wisp”, and wisp doctor passes it when the server answers. From the app, a job SMAppService does not report is still “held by launchd” (orphaned) when it is SMAppService‘s or says nothing of itself, and “registered by” a LaunchAgent file when it names one. Such a wisp never registers a second job of the label: launchctl bootout before its own bootstrap would remove the Login Item’s job behind Background Items’ back, and the two would fight at the next login. Turning the server on, or a change that restarts it, restarts the job that is there (kickstart -k), since the router reads the same ~/.wisp; turning it off and wisp llamacpp agent repair are refused, naming the holder’s own command (/Applications/Wisp.app/Contents/MacOS/wisp config set llamacpp.server off); wisp uninstall leaves it. Handing off to the app’s own wisp, as a link does, was judged and set aside: the two may be different versions, and the person running the app’s own command sees which install acts. Tested with fakes, and the read checked against this Mac’s launchctl print.