# Context hygiene & token management

> Cut My AI Spend — rank #7 of 10. Typical savings: 30–50% of input-token spend. Effort: Medium — ongoing discipline.

Chat histories grow without bound, RAG pipelines stuff 20 chunks where 3 would do, and agents drag full tool outputs through every subsequent turn. Input-side bloat is the quiet half of most AI bills.
Sliding-window histories with periodic summarization, reranked retrieval that keeps only the top few chunks, and tool-output truncation routinely reclaim 30–50% of input spend — and usually improve answer quality, because the model sees less noise.

## How to do it

1. Cap conversation history; summarize older turns into a compact state instead of replaying them.
2. Add a reranker to retrieval and cut passed chunks to the minimum that preserves answer quality.
3. Truncate or summarize tool outputs before they enter the context.
4. Log tokens-per-request per feature; alert on drift.

## Frequently asked questions

### Will trimming context hurt quality?

Usually the opposite — models get distracted by irrelevant context ("lost in the middle"). Measured trimming with evals tends to improve both cost and accuracy.


---
Canonical: https://cutmyaispend.com/methods/context-hygiene
All methods: https://cutmyaispend.com/ | JSON: https://cutmyaispend.com/api/methods.json