Harness engineering

Context management in a coding harness.

Every harness works on a small task. Context management is what separates them at the limit.

Download for macOS
v0.1.33 · .dmg · Apple Silicon & Intel
Signed & notarized by Apple · opens without a Gatekeeper warning
sha256 698955a0187bc039f4c74f5d05a9f10fbb27376a45788a0a241d1326b73873c7
Download for Windows instead
$curl -fsSL https://lucidtrain.com/install.sh | sh

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

TechniqueWhat it buysWhat it costs
Repository mapHigh signal without reading everythingScoring can miss a relevant file
Progressive disclosureA small, navigable starting contextRequires the map to be accurate
CompactionContinuity past the windowLossy; context anxiety persists
Context resetA genuinely clean slateThe handoff must stand alone
Persistent memoryNo relearning between sessionsStale memories mislead
Emergency compactionA turn survives provider overflowExtra latency at the worst moment
FAQ

Questions

Is compaction or a context reset better?

Compaction preserves continuity within a task and is lossy. A reset gives a clean slate and depends entirely on the handoff being complete. Anthropic prefers resets for long-running work specifically because compaction leaves context anxiety in place.

What is a repository map?

A generated file tree with extracted symbols, scored against the current task and injected under a token budget, so the agent gets structural awareness of a large codebase without reading all of it.

Does persistent memory work offline?

In Lucid Train, yes: append-only storage with keyword recall, and optional local embeddings through Ollama when you want semantic search without a network.

Related