Repository navigation
server: POST /v1/prompt_cache/flush drops the prompt cache's kept states - #3210
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/prompt-cache-flush
branch
from
November 14, 2026 03:29
b25144b to
0702445
Compare
4 tasks done
ashhart
force-pushed
the
lead/prompt-cache-flush
branch
3 times, most recently
from
November 21, 2026 05:57
faa353e to
6291ae6
Compare
POST /v1/prompt_cache/flush drops every prompt state kept in RAM and the server's own states on disk (--prompt-cache-disk, --learn-conversations, --spill-gib), and answers what it dropped. The ask waits on the engine thread until no request is in flight; while it waits, the lane host, a family's round planner and Flash Next's serial host admit nothing new, so running replies finish unchanged and the next turn of any conversation prefills cold with the same tokens. Two flushes asked together run in turn. A flush whose 10-minute wait runs out is withdrawn untaken: nothing is dropped and admissions go on. An engine without the shared store answers 501 at once, and a model --idle-unload has parked answers 503 without being loaded. Who may flush is the request cancel route's rule (cancel_ids.allowed): with API keys a full or [admin] key, checked again by the route; without keys only a loopback socket that no proxy header relayed. Fixes #3183
ashhart
force-pushed
the
lead/prompt-cache-flush
branch
from
November 21, 2026 09:52
6291ae6 to
796463d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
POST /v1/prompt_cache/flushdrops every prompt state the server keeps for resuming conversations: those in RAM, and its own states on disk when it keeps them (--prompt-cache-disk,--learn-conversations,--spill-gib). It answers{"object": "prompt_cache.flush", "states", "ram_bytes", "disk_bytes", "disk", "waited_seconds"}.Who may call it: with API keys, a full or
[admin]key (scoped keys get 403insufficient_scope, no key 401, and the route checks the matched key itself). Without keys, only a caller whose socket is on loopback, using the same rule as the request cancel route: the socket address decides, and a request carrying a proxy header is refused with 403loopback_only.Why replies in flight are unchanged: the flush runs on the engine thread only once no request is running. While it waits, the lane host, family round planners and Flash Next's serial host admit nothing new; arrivals queue and start after it. The next turn of a conversation prefills its whole prompt and gives the same tokens it gave resumed. If the running requests have not ended within 10 minutes the flush is withdrawn: nothing is dropped, admissions go on, and the answer is 503. An engine without the shared prompt cache answers 501 at once, and a model unloaded by
--idle-unloadanswers 503 without being loaded. States--learnkeeps for shared prefixes stay on disk.Tests (
zig build test-prompt-cache-flush-host, also intest-lane-api-host,test-server-cpu,test-key-scopes-hostandtest-server-security): after a flush every kept state is gone and a resumed turn prefills cold with the same tokens; a request in flight finishes byte-identical to the same request run alone, the flush answers only after it, and a request queued behind it starts after it and prefills cold; a second flush finds nothing left; a withdrawn flush holds nothing and drops nothing; a host without a cache refuses at once; and each refusal above. Each test fails with its part of the change removed.Stacked on #3193 (it reuses that PR's caller rule); review and land that first. A served check on a model started with a disk store is still owed.
Fixes #3183