Context management in a coding harness.
Every harness works on a small task. Context management is what separates them at the limit.
Context management is how a harness decides what the model sees and what happens when the window fills. The main techniques are selective retrieval such as a repository map, compaction that summarises the conversation in place, context resets that clear the window and hand off structured state to a fresh agent, and persistent memory across sessions. Lucid Train compacts automatically, retries after a provider reports overflow mid-turn, and keeps offline persistent memory.
Selective retrieval before anything else
The cheapest context management is not filling the window. A repository map that extracts symbols per file and injects only what scores against the current task under a fixed token budget keeps the useful signal high without reading everything. OpenAI's framing is progressive disclosure: give the agent a map rather than a thousand-page manual, and keep the conventions file to about a hundred lines as a table of contents rather than an encyclopedia.
Compaction and its limit
When the conversation approaches the window, a harness can summarise older turns and keep the system prompt plus a recent slice. That preserves continuity and it is lossy by construction. Anthropic's write-up names the specific shortcoming: compaction does not give the agent a clean slate, so context anxiety, where a model begins wrapping up prematurely because it believes it is near its limit, can persist through it.
Context reset as the alternative
Rather than summarise in place, clear the window entirely and start a fresh agent with a structured handoff carrying the previous agent's state and next steps. The fresh agent has no accumulated sense of running out of room. The cost is that the handoff has to be good enough to stand alone, which is a design problem rather than a parameter.
What survives between sessions
Compaction and resets both operate within a task. Persistent memory operates across them, and is what stops a harness relearning the same facts about a codebase every session. Lucid Train keeps append-only memory with hybrid keyword and optional local embedding recall that works offline, plus project knowledge in the repository itself so it travels with the code.
Recovering when it goes wrong anyway
The failure that matters in practice is a provider rejecting a turn for context overflow midway through work. Lucid Train performs an emergency compaction and retries rather than surfacing the error, and writes the summary into persistent memory. A harness without that path loses the turn and whatever reasoning was in it.
Techniques and what each costs
| Technique | What it buys | What it costs |
|---|---|---|
| Repository map | High signal without reading everything | Scoring can miss a relevant file |
| Progressive disclosure | A small, navigable starting context | Requires the map to be accurate |
| Compaction | Continuity past the window | Lossy; context anxiety persists |
| Context reset | A genuinely clean slate | The handoff must stand alone |
| Persistent memory | No relearning between sessions | Stale memories mislead |
| Emergency compaction | A turn survives provider overflow | Extra latency at the worst moment |
Questions
Related
- What Is a Coding Harness?Everything in the agent that is not the model. The part you can actually change.
- Harness Engineering vs Context EngineeringOne is a component of the other, and confusing them is why teams optimise the wrong thing.
- Coding Agent vs HarnessAgent equals model plus harness. The harness is the half you control.
- Is Claude Code a Harness?Both, and the confusion is in the question rather than the answer.