Skip to content
mentoor

Topic 5 of 5 · 4 min read

Keeping the context window focused

Goal: Choose when to start a fresh session, summarise or trim attachments in a long chat whose answers have started to drift.

Treat the context window like a desk: keep only what the current task needs on it, and clear it before it gets crowded. A focused window gives better answers, costs less and leaves room for the reply.

Check yourself · 1 of 3

You finish one task and want to start an unrelated one. What is the best habit?

Choose one answer

Why it matters

Long chats pick up clutter: abandoned ideas, old drafts, pasted files you no longer need, tool output from steps that are done. All of it stays in the input on every turn. Answers can drift, the model may follow an old instruction you changed, and you eventually hit the limit. Anthropic's writing on context engineering describes the goal as the smallest set of high-value tokens that gets the job done.

Tools you can use

  1. Start a fresh chat for a new task. A new topic does not need the old history. This is the simplest and most effective habit.
  2. Summarise, then restart. Ask: "Summarise decisions, open questions and key facts in under 200 words." Paste that summary at the top of a new chat.
  3. Compaction. Some tools, including coding agents, do this for you: they replace old history with a short summary when the window gets full. Check what it kept, because summaries drop detail.
  4. Attach only what is needed. Send the section, not the whole document. Remove files from the chat when the task moves on.
  5. Keep stable facts in one place. A short notes file or project instructions beat repeating them across 40 messages.
  6. Trim tool output. If you build with tools, return the few lines needed, not a full log.

Signs it is time to clean up

  • The assistant repeats earlier mistakes or mixes up old and new versions.
  • It ignores a rule you gave a while ago.
  • Replies slow down or begin to get cut.
  • You have switched topics but the chat has not.

Before and after

Before: A 90-message chat about a marketing plan. You now ask about hiring. The assistant adds campaign terms to the job ad.

After: Ask: "Summarise the company facts and tone we agreed, in 150 words." Open a new chat, paste that summary, attach only the role description, and ask for the job ad.

What goes wrong

  • Summarising too early or badly. A summary can drop a detail you needed. Read it before you rely on it.
  • Never restarting. Hoping a long chat will recover rarely works.
  • Restarting with nothing. A fresh chat with no context sends the model back to generic answers. Carry over the facts that matter.

Examples

Summary handoff

Prompt to the old chat: "List the decisions made, the open questions and the facts I must not lose. Under 200 words." Then open a new chat, paste the list as the first message, and continue.

Trim the attachment

Instead of attaching a 120-page handbook to ask about the leave policy, copy the leave section only. The answer is faster, cheaper and less likely to quote the wrong chapter.

Key points

  • A focused window gives better answers, costs less and leaves room for the reply.
  • Start a fresh chat when the task changes, and carry over only a short summary.
  • Compaction replaces old history with a summary, so check what it dropped.
  • Attach only the sections the task needs, and remove files once they are done.
  • Drift, ignored rules and cut-off replies are signs the window needs cleaning.

Common mistakes

  • Continuing one giant chat across unrelated tasks.
  • Leaving large attachments in place after they are no longer needed.
  • Trusting an automatic summary without reading it.
  • Starting fresh without carrying over the key facts and rules.

Check yourself · 2 of 3

A tool compacts a long session into a short summary. What should you do?

Choose one answer

Check yourself · 3 of 3

After 100 messages, an assistant keeps mixing up two versions of a document. Which fix is best?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic