Skip to content
Preptima
hardDesignScenarioMidSeniorStaff

How would you budget the context window for a chat feature backed by retrieval?

5 min readUpdated 2026-08-15

Answer

Short answer

Subtract the answer reservation and the fixed prompt first, give retrieval a token allowance rather than a passage count, and let conversation history have what remains under an explicit eviction policy - because history is the only term that grows every turn while everything else stays flat.

Was this answer helpful?

Likely follow-ups

  • Your rolling summary is itself produced by the model. What happens to it over fifty turns?
  • Do you re-retrieve on every turn or carry the previous turn's passages forward?
  • The user pastes a 30,000-token document into the chat. What does your budget do?
  • How do you tell, from production telemetry, that your eviction policy is throwing away the wrong thing?

Related questions

Masterclass guide

Related Topics