Zenaique

Pick the right fallback when the assembled prompt overflows the model's context window

MCQ·Medium·4.0 · 0·~1 min·Asked atAirbnbDeepseekLambda Labs
Attempt it
TL;DR

The right overflow fallback is a documented eviction order: sacred (system prompt + current turn + output reservation) protected, evictable (extra chunks, summary levels) trimmed in declared order.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a suitcase that will not close. Three bad options. First, refuse to go on the trip until the traveler removes things; rude, and they did not pack most of it themselves. Second, just sit on the lid and squish whatever happens to be at the bottom; you smash the medicine and the passport. Third, secretly trade the suitcase for a bigger one without telling them; they did not budget for a bigger suitcase. The right way is a packing list with priorities. The passport and medicine always stay. The third pair of shoes, the extra snacks, those come out first, in that order, until the suitcase closes. That order is the eviction order, and it is decided before the trip, not on the curb.

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.

Every LLM stack eventually hits the moment when the assembled prompt is bigger than the model's context window. How it responds in that moment defines whether the system is production-grade or a prototype. Four options come up in design reviews, and three of them are wrong in ways that only become visible weeks later when the failures correlate with high-context calls.

The right answer is the least exciting one: a documented eviction order that declares sacred tiers, declares an evictable hierarchy, and trims in declared sequence until the prompt fits. The other three options each fail differently, rejection blames the user, head-truncation decapitates the agent, silent model swap breaks the audit and the bill, but they share a common shape: they are decisions the system makes without informing the caller or the operator, and the consequences arrive in production rather than at design time.

This question is graded as medium difficulty because the wrong answers are tempting. Rejection feels safe; head-truncation is the cheapest to implement; silent model swap preserves the user experience. Each has a clean-sounding rationale and a hidden cost. The correct answer is boring on purpose: predictable, debuggable, and tested in CI.

Why rejection is rarely the right move

Rejection is the cleanest-feeling option. 'Your input is too long; please shorten it.' The user is responsible for what they sent; if it does not fit, that is their problem.

In practice the overflow is almost never caused by the user's literal input. A typical breakdown of an assembled prompt at the moment of overflow:

  • System prompt: 2,000 tokens (fixed).
  • Tool definitions: 2,400 tokens (fixed).
  • Persistent memory or rolling summary: 4,000 tokens (system-managed).
  • Recent conversation history: 12,000 tokens (grows with session).
  • Retrieved evidence: 40,000 tokens (system-fetched).
  • Current user turn: 200 tokens (the only thing the user controls).

The user's 200 tokens is 0.3% of the total. Rejecting because the assembly does not fit is shifting blame for an assembler decision onto a user who cannot influence it.

Rejection is correct in one specific case: when the user's literal turn alone exceeds the input budget after maximum eviction. That happens when someone pastes a 200k-token document into a model with a 128k window. The right response is a clear error code with specifics: 'Input exceeds the maximum supported length by ~72,000 tokens. Please shorten your message or use the document upload tool.' Generic errors ('too long') strand the user; specific errors give them a path forward.

Why silent head-truncation is the worst option
Why silent model swap is the third trap
What the right pattern actually looks like
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
OptionFailure modeWhen (if ever) right
Reject the requestBlames the user for system-side overflowOnly when user input alone exceeds budget after max eviction
Silent head-truncateDrops system prompt and safety railsNever; antipattern
Documented eviction orderQuality degrades gradually under budget pressureDefault for any production system
Silent model swapChanges price and behavior without noticeNever silent; ok with an explicit declared ladder and logging

Real products, models, and research that use this idea.

  • Anthropic Claude Code applies a compaction step before overflow: stale tool results and older summary levels are evicted from working context while CLAUDE.md and the active task block stay sacred.
  • LangGraph's trim_messages with strategy='last' preserves recent turns and the system prompt while trimming older history.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhat does a good error message look like when reject is the correct response?
A

Specific: 'Your input exceeds the maximum supported length by ~N tokens. Please shorten to under M characters or split into multiple messages.' Generic errors ('too long') leave the user guessing. Specific errors give them an actionable shape.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Picking head-truncation as the simple default. It drops the system prompt first, which is exactly the tier that should be untouchable.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Which option is the right default and why

  • What 'sacred tier' means in this context

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Pick the most effective intervention when an agent's context grows by 8KB every iteration
MCQ·Medium