Stackness
Sign up
All moves

Treat an agent's context window as scarce and actively curate it

by Stackness

AI Tools

Rather than stuffing more files, READMEs, and AGENTS.md content into an agent's context, this practice treats context like food in a fridge: keep only what is still useful, move stale or bulky material out via /compact, /clear, subagents, or a second session, and refresh regularly. The underlying claim is that more context often degrades agent performance instead of improving it.

What it is

This move treats a coding agent's context window as a perishable resource rather than a bucket to fill. Every message, file, and tool output you add gets re-read on every turn, and quality does not scale with quantity: performance can degrade well before the window is full, because stale corrections, conflicting docs, and irrelevant files dilute the agent's attention even when there is technically room left.

How to do it

  • Keep the main conversation for work that needs back-and-forth steering, like iterative UI tweaks or quick targeted fixes, since that context is already loaded and useful.
  • Hand off noisy, self-contained investigation to a subagent, for example reading dozens of files or grepping logs, so the mess stays in its context and you only receive a short summary.
  • Start a new session when you switch topics instead of letting unrelated threads pile up in one conversation.
  • Use /compact, /clear, or /rewind to remove or summarize context once it stops being relevant, rather than letting it accumulate silently.
  • Scope tasks explicitly, such as pointing an agent at one directory instead of letting it wander the whole repo, to avoid loading more than it needs.
  • For persistent memory files like AGENTS.md or a project memory bank, read only a small, current-state file every session, and search or grep older history on demand instead of preloading it.
  • Avoid instructing agents to append to memory files after every task by default, since that turns memory into an ever-growing diary that gets reloaded each session.

When it helps

This is useful any time a session has run long, when you are switching between unrelated tasks, when an agent starts making confident but wrong assumptions, or when you notice it slowing down or making more mistakes than earlier in the conversation. It also helps on projects where teams have built up large markdown memory files that get read at the start of every task.

Pitfalls

Stale context is more dangerous than missing context, because missing context creates uncertainty while stale context creates confident mistakes, such as an agent following an outdated architecture doc or payment integration rule. Conflicting instructions from old notes, READMEs, and AGENTS.md files can coexist and force the agent to silently resolve contradictions. Memory systems that mandate updating multiple files after every task tend to produce append-only logs that nobody prunes, eventually costing more tokens than the re-explanation they were meant to save. A fresh subagent also starts cold, so delegating very small or urgent tasks to one can cost more time than it saves.

Sources

Tools