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

+7
View File
@@ -254,6 +254,13 @@ public:
* cache. Takes the step lock because the step path inserts into the map (live sequences hold
* their own block references). See IScheduler::reset_prefix_cache. */
int64_t reset_prefix_cache();
/* Forget one stored conversation, by label or engine id, keeping its first `keep_tokens`
* (IPrefixCache::release_session). Refused with RAD_E_STATE while a request of that
* conversation is queued or running: its blocks would be skipped as live and its close
* would publish the chain again, so the release would be half done and undone at once.
* Takes the step lock like reset_prefix_cache. */
int release_session(const std::string& label, uint64_t id, int64_t keep_tokens,
SessionRelease* out);
/* ---------------------------------------------------------- the step path */
/* One decision, one batch. Null when there is nothing to run, which is not an error. */