LOOK UP · INSPECT · RECOMPUTE

Embedding cache failure: the transform version belongs in the key

Watch concrete requests fill a bounded cache. Inspect stored vectors, expiry, eviction and incorrect reuse.

Exact local cache · synthetic workload

Scroll the diagram horizontally to inspect every label. The panels below give the same state as text.

Request inspector

Resident cache entries

Your experiment

At request five, the feature transform changes from v1 to v2. A document-only cache still reports hits but returns the old vector. Inspect request five, restore the complete key, and compare both vectors. These are transparent word-count features, not learned embeddings or a Java ADK SDK implementation.

Try a correctness failure

Select alternating tenants and omit tenant from the key. The second request reuses team A’s cached envelope for team B. Restore the complete key and verify zero incorrect returns. All data is fictional. This is a key-isolation demonstration, not an authentication implementation.

Transparent transform and timing

v1 counts exact words [cache, agent, model]. v2 reverses those three coordinates. The cached envelope also contains the owning tenant and transform version. A fresh recomputation is displayed as an oracle; its cost is excluded from the teaching latency total. That total is requests × lookup overhead + misses × compute cost. The uncached baseline is requests × compute cost. No network, parallelism, provider prices or real latency measurements are included.

Expiry is insertion time + TTL; hits do not extend it. Expired entries are removed before each request. LRU uses last access; FIFO uses insertion; LFU uses access count then insertion as a tie-break. Counters are reset on reinsertion. Capacity counts entries, not bytes. The sixty-second playback spreads the finite request sequence across an inspection timeline; the actual modeled request clock is shown separately.

Fixture documents

A: cache cache agent
B: agent model model
C: model cache
D: agent agent agent
E: model model cache cache
F: stream queue

A bounded, deterministic teaching implementation. It is not a Redis server, production Java cache, learned embedding model, ADK API implementation, hardware/KV cache or provider context-cache simulator. Redis eviction may be approximate; this model uses exact ordering. Provider prefix caching and semantic-similarity caches have different contracts and are not simulated here. ADK callback caching pattern · Redis eviction concepts.

A high hit rate that is half wrong

Transform changes halfway sends eight requests for document A from one tenant: the first four use transform v1, the last four v2, which reverses the three coordinates. Cache-key dimensions opens as Broken: omit transform version, so the key holds only tenant and text. The preview reports 7 of 8 hits, 87.5 percent, 96 modeled ms against 640 uncached, and 4 incorrect returns. Requests five to eight are hits that return the v1 vector [2, 1, 0] while recomputation under v2 gives [0, 1, 2]; the inspector lists transform version mismatch. Real embeddings fail the same way when the model, chunking or normalization changes: vectors from two versions are not comparable, yet the cache keeps serving the old one.

Put the version in the key

Choose Tenant + transform version + exact text. The run now has 6 hits, 2 misses and 0 incorrect returns for 176 modeled ms. The second miss is request five, the first v2 request, so correctness costs one extra computation. A version bump invalidates without deleting anything: the v1 entry stays resident beside the v2 entry. Set Capacity (entries) to one and request five instead evicts it, recording one eviction with the same hit count. With the version omitted there is only one key, so Capacity and Eviction policy change nothing.

Expiry is not a fix

Return to the omitted version and vary TTL seconds (0 = no storage). At four the entry expires exactly when request five arrives, so the run shows zero incorrect returns by coincidence. At three two are incorrect, and at five one is. Restore TTL twenty. Seconds between requests behaves the same way: five gives zero, four gives one and three gives three. The outcome depends on when the transform changed relative to insertion, which a TTL cannot know. TTL zero disables storage: no hits and 656 modeled ms, more than the uncached 640.

The other inputs

Reload the page for the opening settings. Broken: omit tenant then shows zero incorrect returns because this scenario has one tenant; a test must exercise the dimension it protects. Under Alternating tenants omitting tenant gives four, while omitting version gives none. Request scenario also offers Repeated documents, where Least recently used gives 7 hits, First inserted 5 and Least frequently used 7. Sequence (repeated/custom only) is editable only for Repeated documents and Custom document sequence. Compute cost per miss (ms) and Lookup overhead per request (ms) set the latency estimate: with the complete key, a cost of one and an overhead of fifty give 402 ms against 8 uncached.

Inspection and limits

Inspection time spreads the eight requests over sixty seconds, 7.5 seconds each, so the first incorrect return appears at 37.5 seconds. Play, Pause, Next request, Restart and Speed move through the trace; edits rewind. Choose request or click its history tile shows returned and recomputed envelopes. Common baseline settings loads Repeated documents with the complete key. The vectors are word counts, not learned embeddings; there is no vector index, persistence, model call or ADK cache API.

Views are my own and do not represent any employer, past or present.

Search