Keeping Context Small and Sharp

Summarize, Trim and Load Details Only When Needed

Long tasks fill the model’s window with old steps and stale results. Three habits keep the context useful: compress, prune and load on demand.

Ranjit Nethi

·

Keeping Context Small and Sharp

The short version

  • Long conversations and multi-step tasks fill the window with material that no longer matters.
  • Compress old history into summaries, remove what is finished, and fetch details only when a step needs them.
  • Give each stage of a task its own focused context. Do not use one growing pile.

The idea

As an agent works, its context grows: every tool result, every document and every earlier message stays in the window. Quality drops as the window fills, an effect some engineers call context rot. Three techniques control it.

Compression. Replace long history with a short summary that keeps the decisions, the open questions and the key facts.

Pruning. Remove tool results and documents that have served their purpose. A 2,000-line search result is not needed after the one relevant line has been found.

Just-in-time loading. Keep a short index of what is available, such as file names and record numbers, and load the full content only when a step needs it. This is also called progressive disclosure.

A good project manager does not reread every email at each meeting. They keep a one-page status, close finished items and open the detailed file only when a question comes up.

  1. Work happens
  2. Summarize what matters
  3. Drop what is done
  4. Load details on demand

A fourth technique applies to larger systems: isolation. A sub-task runs in its own clean context and returns only its result. The main task never sees the mess.

An example

A research agent prepares an account plan. It reads 30 documents about the customer. A naive design keeps all 30 in the window, and by the end the model has forgotten the instructions. A better design reads each document in a separate step, saves a five-line note for each one, and writes the plan from the 30 notes. The final step sees about 150 lines of clean notes in place of 30 raw documents.

Common mistakes

  • Summaries that drop the one constraint that mattered.
  • Pruning the instructions along with the clutter.
  • Loading every tool description into every request.
  • No test that compares long tasks with and without compression.

What to do this week

  1. Find your longest-running AI task. Measure the context size at the first step and at the last.
  2. Add a summary step when history passes a set size.
  3. Check that key constraints survive the summary.

The terms, in plain language

TermWhat it means
Context rotQuality falling as the window fills with old material
CompressionReplacing long history with a short summary
PruningRemoving material that is no longer needed
Progressive disclosureLoading details only when a step needs them
IsolationRunning a sub-task in its own separate context

Section 3.2 of the AI Engineering Guide · Last reviewed November 2026

All parts of the guideChecklists and templates

About the author

Ranjit Nethi leads AI and data for commercial operations at a global industrial manufacturer. He writes about the operating model that turns AI pilots into results finance will sign. Kellogg Executive MBA; MS in Computer Science. This site is his own perspective and view, with no affiliation with any organization.