Your context window should fight itself
Most agent harnesses treat the context window as a dumping ground for whatever seems relevant. The model forms a hypothesis, the retriever pulls more items that resemble that hypothesis, and the loop tightens around those relevant results, ever narrower, and narrower with each turn. Confidence rises, correctness often doesn't.
The common failure mode is one-sided evidence drift. The model says "this looks like a race condition." The retriever then serves more race-shaped material because that is what is similar to the current prompt. Nothing in a pure relevance loop can push back. Relevant is computed against the thing being confirmed, so counter-evidence is systematically starved of tokens. If anything contradictory does appear, it's treated like noise.
A better design
Make the context window adversarial to itself. Supporting and contradicting evidence share the window. The contradictions are not mess to clean up...they are what builds up, and you reward the build. Make the window required (in most cases) to hold both sides of a claim even when one side currently looks weaker. The model can still be wrong, but it is harder for it to become confidently wrong by simply never seeing the other side.
This only works if the window is demoted from "the state" to "a rendering of the state."
Facts and intermediate conclusions keep their weight after eviction. Most current harnesses couple a conclusion to the evidence that produced it. Remove the tool result and the conclusion goes with it. 42 turns later the agent re-derives the result, or derives a different one, because the justification is gone.
If the accumulators that hold belief, open questions, rejected hypotheses, and the traces that support them live independently of the window, eviction stops being forgetting. The window can be aggressively pruned, summarized, or even rebuilt. It is only a projection chosen for the next step. The underlying state stays queryable, and 200 turns later, the question "why do you still believe the pool and not the deploy?" can be answered from the traces that produced the belief, not from whatever tokens survived the last 199 turns and compression.
That separation is what makes multiple day long sessions viable in the first place. Without it, every long-running agent is one context compaction away from silently rewriting its own history. With it, the window can stay short, the traces can stay complete, and the agent can be asked to justify its current world model rather than merely continue narrating it.
Relevance retrieval is still useful. It's no longer the only force shaping what the model is allowed to see.