An illustration of a filling context window with three escape valves - compaction, filesystem offloading and a context reset that hands off to a fresh window
Back to blog
Premium
AI AgentsAgentic HarnessContext Management

Context Management: Keeping an Agent Coherent When the Window Runs Out

Sascha KieferAI & Agents

Part three of our agentic-harness series tackles the hardest part of long-running agents: the finite context window. Compaction versus context resets, the problem of context anxiety, filesystem offloading, progressive disclosure, and memory files that carry knowledge across sessions.

This is part three of our five-part series on agentic harnesses. We've covered what a harness is and the loop and tools that let an agent act. Now we hit the part that decides whether an agent can work for ten minutes or ten hours: context management.

The Problem: A Finite Window

Everything a model "knows" in the moment lives in its context window: the instructions, the conversation so far, the files it has read, the output of every tool call. That window is finite, and long tasks overflow it fast. As it fills, two things go wrong: the model loses coherence, and it starts behaving strangely about finishing.

Context management exists to keep the model working coherently anyway. There are a handful of techniques, and the art is knowing which to reach for.

A context window filling toward its limit, with three responses - compact the history, offload bulk output to the filesystem, or reset to a fresh window with a handoff artifact - all feeding back into coherent work

Premium article

Read the full article

Enter your email and we'll send you a link to the complete article — it's free.