Skip to main content

Module slots

Module slots 

Source
Expand description

Slot cache path helpers.

Shared utilities for constructing per-model KV cache slot filenames, used by both gglib-runtime (purge) and gglib-proxy (save/restore).

§Why a flat {model_id}__{session}.bin name, not a subdirectory

llama-server’s /slots/{id}?action=save|restore endpoint validates the filename field with fs_validate_filename, which rejects any path separator (“Invalid filename”, HTTP 400) as a path-traversal defense. A {model_id}/{session}.bin name (an earlier subdirectory-based layout) is therefore rejected outright, silently breaking every save/restore. Encoding the model id as a filename prefix instead keeps per-model scoping (purge removes only one model’s files, matched by prefix) while sending llama-server a separator-free name it accepts.

Functions§

slot_bin_path
Full on-disk path for a model+session slot cache file (flat under slot_dir).
slot_file_name
Filename for a model+session slot cache file: {model_id}__{session_id}.bin.
slot_model_prefix
Filename prefix identifying all of one model’s slot files: {model_id}__.
slot_session_from_stem
Recover the session id from a slot file stem ({model_id}__{session}).
slot_tmp_file_name
Filename for an in-flight save: {model_id}__{session_id}.{nonce}.tmp.