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):
| Option | What it does |
|---|---|
--models-dir PATH | Router mode: one server for every model in a folder, each loaded when first asked for |
--models-max N | At most N models loaded at once (default 4; 0 for no limit) |
--models-autoload, --no-models-autoload | Whether a request loads a model (default on) |
--models-preset PATH | An INI file of per-model settings for the router |
--sleep-idle-seconds N | Sleep after N seconds idle (default off) |
--host, --port | Default 127.0.0.1 and 9931; wisp’s llamacpp.baseURL defaults to port 8080 |
--api-key-file FNAME | Keys 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:
| Question | Result |
|---|---|
| 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:
- 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. - The models it knows. The folder is
~/Library/Application Support/Wisp/llamacpp/models, holding links to GGUF files the person adds withwisp 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. - Whose server:
llamacpp.server, one of three:off, the default: wisp connects tollamacpp.baseURLas today, and starts nothing;wisp: wisp’s own router (decisions 4 to 7);llama-app: wisp usesLlama.app’s router, finding its port, and starts nothing; the person adds models inLlama.app. Its server has no key and answers any origin, whichwisp doctorsays.
- A LaunchAgent keeps wisp’s router running, with idle sleep:
Wisp.appregisters it withSMAppService, 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 signedWisp.appis 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 startsllama-serverin 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. - 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 firstllama-serveronPATH. The proposal of 2026-10-27 named this settingllamacpp.server; amended on 2026-10-29 tollamacpp.serverPath, sincellamacpp.serveris now the choice of whose server (decision 3). A changed digest, as everybrew upgrade llama.cppmakes, is not started: wisp asks the person to approve the new one at the same path, andwisp doctornames the change. Starting it and approving it are audited. - Access. It listens on
127.0.0.1only, 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 (asllamacpp.apiKeyis today). - Memory, set in configuration, each setting explained by
wisp configandwisp doctorwith 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 doctorreports the server, its models, and what is loaded. - Off by default:
llamacpp.serverisoff; 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 mcpand 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 underllama-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, andconfig.jsonholds onlyllamacpp.serverPath, so a path written there by hand is not approved. The digest covers thellama-serverexecutable 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), andllamacpp.serverPort, besidellamacpp.serverPath:llamacpp.serverholds a word, so they cannot sit under it, and theserverprefix keeps them apart from a context length a request asks for. The agent’s label iscom.pidster.wisp.llamacpp, after the notifier’s. - Port. 8933 by default: not 8080, where
offlooks 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. Underwisp,llamacpp.baseURLis not used: wisp askshttp://127.0.0.1:<llamacpp.serverPort>. - No web UI. The router is started with
--no-ui(llama-server 0.7.0’s name;--no-webuiis 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, withO_EXCL, and reused). Underwispit is the only key wisp sends:llamacpp.apiKeyandWISP_LLAMACPP_API_KEYare not used, since the server answers no other, and a key that wins over the file could only ever be refused. - KeepAlive.
{ Crashed: true }withRunAtLoadand aThrottleIntervalof 30 s, rather thanSuccessfulExit: false:wisp llamacpp serverefusing to start (binary changed, setting off) exits 78, andllama-serverfailing 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. WithCrashed, 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, andllama-serverfailing 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
launchctland since removed, leftSMAppServicereporting 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 wispregisters (or, registered, starts it again); setting it otherwise, unsetting it, orwisp uninstallfromWisp.appunregisters it. A change to aserver…setting, an approval of the binary, and a model added or removed restart it withlaunchctl kickstart -kwhen 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 asllamacpp.agent. Everyllamacpp.server…setting is the person’s: the default policy refuseswisp config set|unset llamacpp.server…to the model, and chat’s/configsends 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 awispstarted through a link (whose main bundle is the link’s folder) asks the app’s ownwisp(wisp llamacpp agent register|unregister|status). Otherwise a file in~/Library/LaunchAgents, naming Homebrew’soptpath for a Homebrew install, loaded withlaunchctl bootstrap gui/<uid>. A home other than the person’s, orWISP_LLAMACPP_AGENT=off, registers nothing. launchd keeps no output:wisp llamacpp servesends its own andllama-server’s to~/Library/Logs/Wisp/llamacpp.log. - Signals.
wisp llamacpp serveruns on a thread of Swift’s concurrency pool, which blocks signals, and a program keeps its caller’s signal mask acrossexecve: the first build’sllama-server, and the model process it started, ignored SIGTERM. Every signal is now unblocked and set to its default beforeexecve; the router and its model then stopped within a second of SIGTERM (2026-10-30). - Not tried for real. Registering with
SMAppServiceandlaunchctlwas 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 onKeepAliveand a stale Login Item): the agent ran for real under launchd, with a file in~/Library/LaunchAgentsand withWisp.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.
- Names. The settings are
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.