glossary

Context and retrieval

KV cache

The KV cache stores the attention keys and values already computed for earlier tokens, so a server can continue a prefix without recomputing it, and it is a serving detail rather than a memory the product can read or edit.

Abracadabra Team Glossary

How it works

In a transformer, each new token attends to earlier tokens through keys and values computed at every layer. Those tensors are the KV cache. During a prefill the server computes them for the prompt. During decoding it appends one token at a time and reuses the cache instead of recomputing the prefix. That is why a long shared prefix is expensive once and cheaper to continue. Prompt caching, as an API feature, is often this reuse made available across requests when the prefix tokens match exactly. The cache is still an implementation detail of serving.

Nothing in the product reads the cache as notes. A clerk cannot open it and recover a mortgage figure that was never written to a database. Change one token of the prefix and the cached keys for the suffix are no longer valid. The cache does not fuzzy-match a similar prompt, and it is not the agent's memory of a customer. If a dashboard exposes cached tokens, that number is about reuse of computation. It is not evidence that a fact was stored on purpose.

A worked example

Keys and values kept for a firm's standard undertakings

A conveyancing assistant streams a completion checklist. The server has already run a prefill on the fixed system prompt plus the firm's standard undertakings, and it holds the keys and values for that prefix in memory. Each new token of the checklist attends to those tensors instead of recomputing them. The clerk watching the stream cannot inspect the cache or correct it. The buyer's mortgage offer is not in there as a field. It is in the case file, or it is absent. When someone edits a single undertaking, the prefix tokens change, the server drops that cache, and the next checklist pays for a full prefill again. The edit changed the instructions. The cache drop was the serving consequence.

Illustrative example, not a production trace and not a measured result.

What goes wrong

  • A team treats the KV cache as a customer memory and is surprised that a preference vanishes when the prefix text changes. That preference was never written to a store the harness can reload.
  • A dynamic header is prepended to every request, the cache never reuses the real system prompt, and prefill latency stays high with no change in answer quality.
  • Someone expects a similar question to reuse the cache because the meaning matches, and the server recomputes because the tokens differ.

How to measure it

Use what the server actually exposes: prefill time, time to first token, and cached-token counts if the API reports them. Pair a cache miss with a diff of the prefix, not with a theory about forgotten facts.

Do not score answer quality as a KV-cache metric. If replies slow down after a prefix edit and people abandon them, compare task success and latency for that cohort with the previous prefix.

Further reading

How Abracadabra helps

Slower first tokens after a prefix edit are a serving symptom of lost reuse. They are not, by themselves, a wrong memory. Compare latency and task success for that cohort once the prefix is stable again.

When context is lost, people restate a fact or repeat the request. Abracadabra pins those corrections and repeated intents to the turn. After a change to what the agent keeps, compare task success for that task and cohort with the previous period.

Request access to read this on your own agent.

See it in your own agent's conversations.

Each task, the step where it stops, and the conversations behind every count. Free during early access.