Full Context or Retrieval: Choose by Corpus Size, Cost and Freshness
Three document sets, three answers. A small stable handbook is best sent in full with a cache, a 2.4 million token archive must be retrieved, and hourly price notes keep resetting the cache, so retrieval wins.
What you will learn
- Check whether a document set fits in one request before anything else
- Cost a corpus per day three ways: full, full with a prompt cache, and retrieval
- Explain why a corpus that changes often resets the cache and favours retrieval
- Pick full context with a cache for small, stable, busy sets, and retrieval otherwise
Before you start
- Why RAG exists
- Prompt caching: keep the start of every request identical
Our support team has three sets of documents, and Claude has to answer from them. Someone asks: can we just paste every document into the request? Sometimes yes, sometimes no. Three things decide it: size, cost and freshness. We'll cost each set both ways with a tiny project of our own.
If you haven't met retrieval yet, why RAG exists explains the idea. This article is the decision, in numbers.
Three document sets
| Set | Size | Questions a day | Changes a day |
|---|---|---|---|
| Staff handbook | 40,000 tokens | 300 | 0 |
| Support archive | 2,400,000 tokens | 150 | 0 |
| Price notes | 60,000 tokens | 300 | 24 |
These are our own example numbers, kept in corpora.py along with the window size (1,000,000 tokens on current models, from the Claude docs page on context windows) and a retrieval budget of 4,000 tokens of passages per question.
The binder or the index
You need answers from your files in a meeting. One way is to bring the whole binder: nothing can be missed, but it's heavy, you carry it every time, and a whole library won't fit in the bag. The other way is to ask the index which pages matter and carry only those. It's light and quick, but the index can miss a page and has to be kept current. Full context is the binder. Retrieval is the index plus a few pages.
Three questions, in this order
How the bill adds up
- Full, no cache: the whole set at full price, on every question.
- Full, cached: the first request writes the set at 1.25 times the base price (the 5-minute cache). After that each read costs a tenth. Every change forces a new write, because the stored copy is out of date.
- Retrieval: only the passages, 4,000 tokens a question. The index itself has its own cost and isn't priced here.
The unit is one base input token. The multipliers come from the Claude docs page on prompt caching; some models list a lower read price.
"""Daily input cost in base units: 1 unit = one base input token."""
from corpora import PASSAGES, WINDOW
# 5-minute cache write, times the base price
WRITE_5M = 1.25
# cache read, times the base price
READ = 0.1
def full_plain(c):
return c["questions"] * c["tokens"]
# assumes questions arrive less than 5 minutes apart: the cache stays warm
def full_cached(c):
writes = 1 + c["changes_per_day"]
reads = c["questions"] - writes
return writes * WRITE_5M * c["tokens"] + reads * READ * c["tokens"]
def retrieval(c):
return c["questions"] * PASSAGES
def fits(c):
return c["tokens"] <= WINDOW
Note the assumption on full_cached: questions arrive less than five minutes apart, so the cache stays warm. Every read refreshes the five-minute window.
Run choose.py
def choose(c):
if not fits(c):
return "retrieve: it does not fit in one request"
if c["changes_per_day"] > 0:
return "retrieve: every change resets the cache"
return "full context, cached: stable, and about the same cost"
No model is called, so no key is needed:
Staff handbook: 40,000 tokens, 300 questions, 0 changes a day
full, no cache 12,000,000
full, cached 1,246,000
retrieval 1,200,000
-> full context, cached: stable, and about the same cost
Support archive: 2,400,000 tokens, 150 questions, 0 changes a day
full does not fit in one request
retrieval 600,000
-> retrieve: it does not fit in one request
Price notes: 60,000 tokens, 300 questions, 24 changes a day
full, no cache 18,000,000
full, cached 3,525,000
retrieval 1,200,000
-> retrieve: every change resets the cache
The choice, set by set
- Staff handbook. Cached full context costs 1,246,000 a day against 1,200,000 for retrieval: about the same. Full context with a cache wins because it's stable and simpler, with no index to maintain, as long as questions keep the cache warm. Without the cache it would be 12,000,000, ten times more.
- Support archive. 2,400,000 tokens is over the 1,000,000 window. Size decides; retrieval is the only way.
- Price notes. 24 changes a day means 25 cache writes. Cached full context costs 3,525,000 against 1,200,000 for retrieval. Retrieve, and re-index on every change. A stale document gives an old answer that still sounds sure.
Limits of caching the full set
- Cached tokens still count toward the window. The price drops; the size doesn't.
- More context isn't automatically better. As the token count grows, recall can degrade. The Claude docs call this context rot.
- Caching pays only when many questions arrive inside the five minutes and the set stays put.
The caching mechanics are in prompt caching. Whichever route you pick, the request should still cite its sources and be able to say not found, as in citations and abstention.
Recap
| Corpus | Deciding factor | Choice |
|---|---|---|
| Small, stable, busy | Cost is about equal | Full context, cached |
| Bigger than the window | Size | Retrieve |
| Changes often | Freshness resets the cache | Retrieve, keep the index current |
Pick the answer that weighs size, cost and freshness together, not one that always pastes everything or always retrieves.
StudyEasy AI Community
Learn AI engineering, share what you build, and connect with other learners.
Free resources: lesson files, notebooks and code
Ask questions and join engineering discussions
Meet real people learning and building with AI
Related course on Udemy
Claude Certified Developer - Foundations (CCDV-F) Exam Prep
Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)Related posts
The Claude Messages API: Your First Call, Field by Field
One request in, one Message out. The four fields of a Messages API call (model, max_tokens, system, messages), how to read content blocks, stop_reason and usage, and why every turn resends the history.
Claude Tool Use: How tool_use and tool_result Work in the Messages API
Follow one order question through Claude's tool round trip: define a tool, read the tool_use block, run your own function and send a matching tool_result back, including parallel calls and is_error.
Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
Every Claude client SDK wraps the same REST request: a POST to /v1/messages with a JSON body. See it built by hand, through the Python and TypeScript SDKs, as typed errors, and as async calls that wait together.
Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
Configure the Anthropic SDK client (timeout, max_retries, with_options, async, pagination), see which errors it retries by itself, then repair a retry wrapper so a 429, a 529, a 400 and a timeout each get the move the docs support.