Skip to content

A cancelled request keeps its cache outcome, and the dashboard shows it as cancelled - #652

Open
jvmenen wants to merge 3 commits into
youssofal:mainfrom
jvmenen:fix/cancelled-stream-record
Open

jvmenen wants to merge 3 commits into
youssofal:mainfrom
jvmenen:fix/cancelled-stream-record

Conversation

@jvmenen

@jvmenen jvmenen commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Why

When a client closes a streamed turn during decode, the server writes a short receipt that always says session_cache_hit: false, without cached_tokens, cache_source or ttft_s, whatever the cache really did. The dashboard then shows the row as a yellow "MISS" and counts it against the hit rate. In one case, a 92,819-token turn restored 92,636 tokens from RAM and was then closed by the client after 180 s: the request log listed it as a cache miss.

How it works, in plain terms

The cache outcome is known as soon as the prompt has been read. The "prefill completed" event now carries that outcome, and the server keeps it per request in a small bounded ledger. When the request is cancelled, its receipt takes the outcome from there. If the request was cancelled before its prompt was read, the cache fields are null (unknown), not false.

What changes

  • Server: the cancellation receipt carries the cache outcome (session_cache_hit, cached_tokens, cache_source, cache_miss_reason, the SSD fields) and ttft_s. Unknown values are null.
  • Dashboard: a cancelled row gets a grey badge with the reason and duration, for example cancelled · client · 3m 0s, with its real cache outcome next to it (hit 92,636). Cancelled rows are left out of the hit rate. Receipts from older servers show no outcome rather than a false miss. The served bundle is rebuilt from the frozen lockfile.

Tests

  • Python: a cancellation receipt carries a known hit, a known miss with its reason, and ttft_s; a cancel before the prefill completed records null; a normal receipt releases its ledger entry.
  • Dashboard (bun test): the badge and tooltip, the cache hint, older receipts, and the hit rate without cancelled rows. tsc --noEmit passes.

A streamed turn the client closed during decode was recorded with
session_cache_hit False and no cached_tokens, cache_source or ttft_s, so it
read as a cache miss even when its prompt had been restored from RAM.

The completed prefill event now carries the cache outcome as the request's
stats will report it (cache_source, cache_miss_reason, the SSD fields and the
served restore record). The server keeps that outcome per request in a small
bounded ledger, and the cancellation receipt takes it, with ttft_s measured
as in the normal receipt. A request cancelled before its prefill completed
records the outcome as null, not as a miss. Normal receipts release the
ledger entry.
A cancelled row fell back to the HIT/MISS badge, and with the old receipt
always to MISS. It now gets its own badge with the reason and the duration
(for example "cancelled · client · 3m 0s"), a tooltip with the raw reason,
and its cache outcome beside the badge when the server knew it. The session
cache hit rate leaves cancelled requests out.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant