Back to all articles
Cutting LLM Costs Without Losing TrustPart 10 of 12
LLM costsCaching

Cache the Lookup, Not Just the Answer

Janahan Thavendran7 min read

TL;DR

  • Below the answer cache sits repeated work: cache retrieved chunk IDs by index version, cache CRM reads with clear-on-write, cache question embeddings and coalesce identical requests in flight.
  • Prefetching the account bundle when a meeting is booked cuts a prep run from 8 steps to 5, saving $44 to $329 a month depending on what Part 7 already did, and three round trips before the deadline.
  • At this team's size the retrieval stack costs tens of dollars a month, so retrieval caching saves seconds more than dollars; stale data and permissions are the risks to design for.

Part 10 of 12 in the series Cutting LLM Costs Without Losing Trust. Part 1 cached answers and Part 2 cached the prompt. This part caches the work in between: the searches, the CRM reads and the account facts an agent fetches step by step.

Picture the Monday after a launch. Between 9:00 and 9:10, forty reps ask the assistant about the new SSO add-on before their first calls.

The semantic cache from Part 1 has no answer for it yet. The first request is still running when the second arrives, so all forty miss, and forty identical model calls run side by side. Down the hall, the prep agent from Part 7 is getting five reps ready for Acme meetings. By 9:30 it has looked up the same Acme account eleven times.

Nothing was wrong with any single call. The same work was being done again and again, one layer below the cache.

Four things worth caching below the answer

Retrieval results. Cache the IDs of the chunks a normalised question retrieves, tagged with the version of the index they came from. Unlike Part 1's answer cache, this one doesn't skip the model: the question still gets routed, trimmed and answered fresh. So it works with every other lever instead of around them, and it's safe for questions too account-specific to cache as answers. When the index changes, the version tag retires the old entries.

Tool results. Cache CRM reads, open ticket counts and usage numbers for a few minutes. Twenty agent runs that need the same account in one morning then read it once. The rule that matters is read-your-writes: when a rep changes a field, clear that record from the cache at the same moment, so the rep never sees the value they just replaced.

Question embeddings. The same questions come back far more often than the same answers can be served, because many are account-specific. Caching the embedding of a repeated question skips one call on every search.

Requests already in flight. When identical requests arrive while the first is still running, hold them and give them the first one's answer. Part 1 called this single-flight in its rollout plan; it's what stops the forty-rep stampede above from becoming forty model calls.

Prefetch: fetch before the agent asks

Part 6 built briefs when meetings were booked. Do the same for the facts an agent would otherwise look up one by one. When a meeting is booked, assemble an account bundle: the CRM record, open tickets, the last few email threads, the renewal date. Hand it to the agent at the start, with its IDs for every system.

In Part 7's runs, that removes about three lookup steps, taking a normal run from 8 steps to 5, while the starting context grows from 5,000 to 6,500 tokens. For the 3,600 normal prep runs a month:

Setup
Sonnet 5.5, no prompt cache
Per run, before
$0.204
Per run, with prefetch
$0.113
Monthly saving
$329
Setup
With Part 2's prompt cache
Per run, before
$0.055
Per run, with prefetch
$0.036
Monthly saving
$71
Setup
With the cache and Part 7's step routing
Per run, before
$0.039
Per run, with prefetch
$0.027
Monthly saving
$44

On Part 7's full setup, the prep agent's monthly bill falls from $160 to about $118. The dollars are small because Part 7 already did most of the work. The time isn't: three fewer steps are three fewer round trips before the 9:55 deadline. If a meeting is cancelled, the bundle is wasted, but it's data, not model calls, so it costs very little.

Cheaper retrieval

The retrieval stack has its own levers, and they mirror the ones for models:

  • Filter before you search. Keyword and metadata filters first, embeddings only on what survives. Part 4's version and account filters are the start of this.
  • Cascade the search. Take five results cheaply. Rerank only when the top scores are close or low, and widen the search only after that. It's Part 3's cascade, one layer down.
  • Drop near-duplicates within a result set. Three versions of the same pricing chunk use three slots. Keep the one that holds the exception.
  • Use a cheaper reranker or fewer candidates. Reranking 30 candidates costs more than reranking 10. Check the precision you keep on the golden set.
  • Shorter embeddings. Some embedding models let you request shorter vectors, which cuts storage. Check recall with Part 4's survival rate before you switch.
  • Tier the vector store. Keep live content hot, move the long tail to cheaper storage, and delete old versions on a schedule.
  • Re-embed in steps. Version your embeddings, and never mix two embedding models in one index: recall drops quietly when you do.

Be honest about the scale. For this team, the retrieval stack is small: question embeddings cost cents a month, the reranker about $20 (Part 4) and the vector store its $50 minimum (Part 1). Caching retrieval here saves seconds more than dollars. The dollars show up with much bigger document sets, much higher volume, or once the vector store outgrows its minimum.

Route to the warm cache

Each model keeps its own prompt cache, as Part 7 noted. When two tiers would both answer a request well, prefer the one whose cache is already warm. In practice that mostly means keeping a conversation on the tier it started on, which Part 3 already recommends for consistency. Only apply it between tiers the router has already judged good enough, or quality drifts toward whichever model happens to be cached.

Where it bites

Stale data. A cached deal stage outlives the change a rep just made. Clear on write for the rep's own changes, keep the time limits short for everything else, and never cache anything that has to be current to be right, such as a discount approval.

Permissions. Reps see different fields on the same account. Key every cached CRM read by the user's access as well as the record, the same partitioning Part 1 used for answers.

Waiting on the first request. Requests held behind a slow first request inherit its delay. Give them a timeout after which they run on their own.

Layers nobody checks. Track the hit rate of each cache layer. A layer with no hits is only extra latency and extra code.

The cheapest step is the one the agent doesn't take

Part 1 asked whether a question had been answered before. This part asks whether the work behind it had been done before: the search, the lookup, the account fetched for the third time this morning.

For a live assistant, most of that saving is time. For an agent, time and money are the same thing, because every step it doesn't take is a step it doesn't pay for.

The series

Each part uses the same sales assistant, so the savings stack on top of each other.

  1. Semantic caching: stop paying for the same answer twice
  2. Prompt caching: stop re-reading the same playbook on every call
  3. Model routing: use the big model only when the question needs it
  4. Trimming retrieved context: two good chunks beat ten average ones
  5. Controlling output length: your sales assistant talks too much
  6. Batch processing: not everything needs an answer right now
  7. Budgets for agent loops: your agent doesn't know when to stop
  8. Small models and fine-tuning: you probably don't need to fine-tune
  9. Prompt and context compression: your prompt is longer than the question
  10. Retrieval and tool-result caching: cache the lookup, not just the answer (this post)
  11. Commercial and governance levers: the biggest discount isn't in the code
  12. Cost per outcome: stop counting tokens, count deals

Next up, Part 11: commercial and governance levers, the savings that don't live in the code.

Sources

The prefetch figures assume three lookup steps removed and 1,500 tokens added to the start of each run. The scenario at the top is illustrative.