Pure projection of a ProviderUnloadAction into the request that will be
sent. Separated from execute_unload_request so the model-tag override
and body-rewrite logic is fully testable without a live HTTP server.
Outcome of dispatching a single ProviderUnloadAction. The planner owns
execution (#kgunloadpost) so any caller — tsift kg unload, a future
lease-drop hook, or the lifecycle swap path — gets the same POST behavior
without re-implementing the HTTP fallback chain.
Default llama.cpp router unload endpoint. Also the value llama-server
listens on by default. Override via --provider-endpoint or the
TSIFT_LLAMA_CPP_ENDPOINT env var when this port is taken (e.g. by a
local WordPress instance at 8080).
Plan + execute a full unload action chain in one call. The default path
for callers that don’t need to inspect the prepared request. Skips non-API
actions (noop, process-exit) by reporting them as not executed.
Dispatch a single prepared request: POST the body, fall back to the
subprocess command if the HTTP path fails. Impure — exercised end-to-end
via the tsift kg unload smoke; unit tests cover prepare_unload_request
and rewrite_unload_body_model instead.
Normalize an unload endpoint into the canonical /api/generate path used
by Ollama’s keep_alive:0 contract. Tolerates callers that supply the
base host (http://host:11434) or the full generate URL.
Rewrite the model field of an unload action body to honor an explicit
--model override. build_unload_actions formats the body with the
profile’s model_ref, so without this rewrite the override would be
silently ignored. Falls back to the original body if JSON parsing fails
(defensive — the planner’s body templates are always valid JSON).
Fire-and-forget unload for callers that don’t have a full action plan —
used by tsift kg smoke --unload and any future lease-drop hook that just
needs to push a single model out of VRAM. Builds a minimal Ollama
keep_alive:0 request and dispatches it.