Repository navigation
feat(offload): cacheanchor, a breakpoint before the first edited message, and mask deep_batch - #495
OsherElhadad wants to merge 1 commit into
Conversation
…t before the first edited message Signed-off-by: Osher-Elhadad <Osher.Elhadad@ibm.com>
|
Review of af57def. go vet, gofmt clean; CHANGES REQUESTED Blocking
Non-blocking Re-review after 1 and 2. Not labelled. |
What
An edit inside the cached history normally makes the provider write everything after the system prompt again: the client marks only its last message, and the provider's look-back is 20 blocks. This PR adds a pipeline-level component,
cacheanchor, that keeps such an edit to a tail rewrite, and adeep_batchoption formaskthat makes use of it. Both are opt-in:cacheanchoris in no preset anddeep_batchdefaults to 0.How it works
cacheanchorruns last. It compares the request with the thread's previous forwarded request and finds the first message p where they differ.cache_controlmark on the assistant turn that follows the latest earlier request end whose forwarded prefix is unchanged and whose entry is younger than the cache lifetime. That breakpoint looks back one block, finds the entry the earlier request wrote, and reads the prefix up to it; only the tail is rewritten.anchor_no_valid_entry,anchor_not_markable,anchor_no_free_slot; event:anchor_placed.maskwithdeep_batch: Nlifts the cached-prefix gate on a turn when N or more older outputs are waiting, masking them together (one rewrite instead of one per turn). Decisions are still frozen and replayed byte-identically.Tests
Unit tests for the anchor (placement, cap, TTL, cold request, appends), for
deep_batch, and a wire test throughapply.BodyOptswith a Claude Code shaped body: with[mask, cacheanchor]an assistant turn carries the mark and no request exceeds four breakpoints; the control withoutcacheanchorcarries none.Related: #475 uses the same idea inside
extract_llm_ride.