server: DELETE /sessions forgets one stored conversation

A client that deleted a conversation, or compacted it past a prefix, knows the
rest is dead before --prefix-cache-ttl does. DELETE /sessions/<label> (or
?label=, ?id=<engine id>) walks the session's chain from the tip inwards like
expiry: VRAM blocks to the pool, the host copy with them, the session's
snapshots to the store. ?keep_tokens=N keeps the chain's start in whole blocks.
Blocks another stored session shares (the system prompt) and blocks a live
request reads stay and are counted apart; the row is cut at the deepest block
that stayed, so a later release reaches it. A request of the same conversation
in flight is 409. IScheduler::release_session beside reset_prefix_cache,
PrefixCache::release_session over the tiers' session table (find_sessions,
shared_prefix_blocks, cut_session). Counters released{entries,snapshots} on
/sessions and /stats, prefix_cache_released_total{what} on /metrics.
This commit is contained in:
Nunze committed 2026-10-22 09:58:08 +00:00
1 parent 123c439684
commit 3aded1bbf8
20 files changed
+722 -2

No files matched your search

+10
View File
@@ -424,6 +424,16 @@ struct FakePC : IPrefixCache {
std::vector<uint64_t> holds, releases;
void hold(const Request& r) override { holds.push_back(r.id); }
void release(const Request& r) override { releases.push_back(r.id); }
/* What the scheduler asked to be released, recorded; the answer is canned. */
struct Released { std::string label; uint64_t id; int64_t keep_tokens; };
std::vector<Released> released_calls;
int release_rc = RAD_OK;
int release_session(const std::string& label, uint64_t id, int64_t keep_tokens,
SessionRelease* out) override {
released_calls.push_back({ label, id, keep_tokens });
if (out) { *out = SessionRelease{}; out->sessions = 1; out->entries = 5; out->tokens = 80; }
return release_rc;
}
/* What the reserve asked for, call by call. */
std::vector<int64_t> trims;
int64_t trim(int64_t n) override {