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.