You have a 16k-token window for a customer support chatbot. Propose a budget split across system prompt, persistent memory, rolling summary, recent verbatim turns, and retrieved KB chunks. Justify the priorities.
Protect output reservation and system prompt first, allocate the biggest content slot to retrieval, give recent turns more space than rolling summary, and keep slack to avoid prompt-cache misses.
Picture packing for a flight with a hard weight limit on the bag. Some things are fixed and non-negotiable: the boarding pass, your passport, the clothes you will wear off the plane. Those go in first and you do not weigh them again. After that, you allocate the remaining weight by how badly you need each thing. The textbook for the trip gets a lot because it is the whole point. A small notebook of personal preferences earns a little space because it changes every trip. Old itineraries from last year get a single summary card, not the full paper. And you leave a little slack so the bag still closes when you stuff something in at the gate. A token budget is the same shape.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
A context-window budget is a multi-objective allocation problem. Each slot competes for the same finite token pool, but the slots are not interchangeable. Some carry the dominant signal for the task; others are scaffolding; some are non-negotiable. The art is in the priority order, not the exact numbers.
This card walks through a defensible split for a 16k-token customer-support chatbot, the reasoning behind each allocation, and how to evict under budget pressure without breaking the answer.
The four-tier priority
Every context-window allocation falls into one of four priority tiers. The tiers are about flexibility under budget pressure, not about absolute size.
Tier 1: Protected. Slots that cannot float. Output reservation and system prompt. The output slot is sized by the task floor, the smallest answer the system has to produce without truncation. The system prompt is sized by the rules the model must follow. Both are roughly fixed for a given application.
Tier 2: Signal-carrying. Slots that carry the dominant information for the task. For a grounded support chatbot, that is retrieved KB chunks and recent verbatim conversation turns. These two get the biggest share because the answer literally depends on what is in them.
Tier 3: Scaffolding. Slots that provide coherence and personalisation but are not the main signal. Rolling summary (connective tissue for older conversation) and persistent memory (cross-session user facts). These get modest budgets because their value is in being present at all, not in being large.
Tier 4: Slack. Tokens reserved for variation and prompt-cache stability. Not a content slot; the absence of slack causes production failures even when the content slots are sized correctly.
Why the order matters
When the budget tightens, you evict from the bottom of the priority list. The order determines what the system degrades to under load, which is what production correctness depends on.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Anthropic's Claude Opus 4.7 support-chatbot reference architecture uses a similar split: large retrieval slot, generous output reservation, modest rolling summary.
- LangGraph's MemorySaver-plus-retrieval pattern for production support agents explicitly separates persistent memory from rolling summary as different stores.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you change this split for a 200K-token window?
Output reservation and system prompt stay similar; retrieval can stretch to top-10 or top-15 chunks; verbatim turns can carry more history without needing summarization; rolling summary becomes optional for moderate-length conversations.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Splitting the budget evenly across all slots, or letting output reservation float. Output tokens are fixed by the task, not negotiable against input; treating them as flexible is how production prompts truncate mid-answer.
60 second bullets to scan on the way to the call.
Which slots are protected and why output reservation tops the list
Why KB chunks get the largest content slot for a grounded task
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.