Introduction
The most common failure I audit: RAG everywhere, or context-window-only, or a vector DB storing order status. Each mistake has a predictable symptom. Slow retrieval. Hallucinated answers. Runaway token costs. Agents that forget the moment a session ends.
This note is the four-type decision rule. For the three-paradigm view (implicit, explicit, agentic), see agent memory three types. For where RAG sits in the pipeline, see complete RAG pipeline.
Type 1: Context window (short-term)
Session memory. Free per turn. Gone when the session ends. Use for the current conversation, recent tool results, and the active task.
Do not stuff entire knowledge bases into the context window. You will burn tokens and hit limits by week two. Rule: if it only matters for this turn, keep it in context.
Type 2: RAG (long-term vector)
Retrieve only what is relevant from a large, changing corpus. Company docs, product catalog, support history. Lives in Chroma, Faiss, Pinecone, or pgvector.
Avoid RAG when knowledge is small and stable. A 20-page policy that fits in context does not need a vector index. It only adds latency.
Type 3: CAG (cached context)
Stable knowledge the agent needs all of, every time. Policies, pricing rules, system instructions. Lives in the prompt cache at the model layer. Up to 90% cheaper than uncached input tokens on cache hit.
Avoid CAG when knowledge changes frequently or does not fit in the context window. The content quality pipeline uses CAG for stable 80-item rubrics for exactly this reason.
Type 4: Database (structured)
For facts the agent reads and writes: order status, ticket state, user preferences. Postgres, MongoDB, Redis. Predictable, queryable, transactional.
Storing order status in a vector store means semantic search on a primary key. That is a bug, not a feature. Rule: if the agent needs to write, use a database.
The decision rule
| Question | Memory type |
|---|---|
| Retrieve from a large corpus? | RAG |
| Need everything every time? | CAG |
| Need to write a fact? | Database |
| Only matters this session? | Context |
Conclusion
Open your agent code today. For every piece of state, ask which of the four types it belongs to. Move the misplaced ones. Your latency and your bill will both thank you.


