2026.06 · 6 min

Context Dilution

A rule you agreed on at turn 1 is gone by turn 100, with no error. The popular fixes don't work: a memory vault, one agent managing another. The only thing that does is moving what matters out of the context window, where it can't dilute.


Dilution is a silent failure: no error, no flag. A rule you agreed on at turn 1 is gone by turn 100.
The popular fixes don't work: a memory vault, one agent managing another. You can't out-prompt physics.
The fix: stop asking the model to remember. Move what matters out of the window, where it can't dilute.
Then audit it. “The mechanism exists” and “the mechanism is still firing” are different facts.

1. What it is

You set a rule at the start of a session. “Update the changelog after every change.” Twenty turns in, it's still holding. Around turn one hundred it quietly stops, buried under everything that came after, and you don't notice until you go looking.

That's context dilution. It follows from three facts about LLM agents you can't engineer away. The context window fills up, so a line-one instruction fights hundreds of messages for attention by turn one hundred. There's no cross-session memory, so today's lesson is gone tomorrow. It's stochastic, so you can't bet on “it should remember.”

Together: you can't rely on an agent retaining any given rule, over a long enough session.

2. Why it's worse than a bug

A bug throws an error. A stack trace points at a line. You can fix what you can see.

Dilution shows you nothing. A rule you thought was running just stopped, at some moment you weren't watching. No error, no failing test, no red. The mechanism was there the whole time and stopped working.

And it generalizes. Every mechanism you build has three checkpoints, each able to fail silently:

  1. Designed to run: the rule exists, the logic is correct.
  2. Actually runs: wired up, registered, triggered on the right event.
  3. Actually produces a result: running, and the output is real.

Break one and the mechanism looks like it's protecting you while protecting nothing. Most people only check the first: “I wrote the rule, it's in the file.” The failures live in 2 and 3. The question is never “did I add the rule?” but “is it still firing, and is its output real?”

The internet bolts something flashy on top: Obsidian to “manage memory,” one agent supervising another so it looks organized.

A memory vault doesn't escape dilution, it reorganizes it. The notes still have to be read back into the window to do anything, where they fight for attention like everything else. Prettier storage, same physics.

The subtler version: make it remember harder. Longer configs, angrier reminders, more prompt. Same problem, because a bigger rule is still a rule competing against everything downstream.

The test isn't where the text is stored, it's whether the mechanism needs the model to notice it to work. If it does, it can be diluted. The only things that can't are the ones that act outside the model's attention entirely.

3. The fix: move it out

Two roads. Make it remember better, which is doomed. Or admit it can't, and move what matters out: to a script that fires on every action, a file system with permissions drawn, a log that compiles itself into rules. Somewhere the window can't reach.

That's the core move. The rest is the same instinct at different scopes.

One fork. Move things out as primitives (a file system, a gate, a log) or as scaffolding (instructions written to patch what today's model can't do). The smarter the model gets, the more primitives pay off and the more scaffolding you have to tear out. Build with primitives and you don't have to redo this layer when the model improves.

4. Where the rules live

They need somewhere to live, and not one file. Sort by one question: would this rule survive a long conversation? If not, it sinks.

LayerWhat lives hereDecays?
Global configSoft preferences: style, toneYes, doesn't matter
Project configProject map: what to read, who owns whatYes
Skills (load-on-match)Topic rules, loaded only when hitDoesn't bloat context
Output styleReplaces the system prompt, re-injected mid-sessionResisted, not immune
HooksHard rules, fire on every actionNo
Auto-memoryCross-session learningPersistent

If decay does no harm, it lives up top; if decay would hurt, it sinks. Hooks are bedrock: they don't live in the conversation, so no conversation is long enough to dilute them. The discipline: deterministic goes to a hook, discretionary goes to a skill. Anything that must happen belongs in a hook, never in a skill's best-effort matching.

5. How I fight it

Each defense maps to one way dilution fails you.

Hard rules sink into hooks. A pre-write gate (pretool_approval_gate.py) splits the file system into a free-write zone (drafts, notes, logs) and a canonical zone (README, the live site, anything user-facing). Reach for canonical, or try to write past a line threshold, and it stops until a recent message of mine carries an approval token. It can't be diluted, because it's not a rule in the prompt but a gate outside it, and it fires even under “skip all permission checks.” The judgment “what's it allowed to do right now” is itself state that goes missing in a long session, so I moved that out too.

Behavior rules become a re-injected layer. The output style replaces the system prompt instead of appending, and re-injects as the conversation grows, so the rules stay near the front instead of aging into the backlog. This still lives in context, so it isn't immune, only the most resistant thing that does. Replacement and recency are what separate it from “remember harder”: it refreshes the rules in place rather than piling more text on top of them.

Corrections turn into a log. When I correct it, a stop hook (stop_enforce_lessons.sh) won't end the turn until the correction lands: what went wrong, the rule, the root cause. Each lesson carries a tag. [active] means I'm still enforcing it by hand; once I move it into a hook I flip it to [codified] and it stops loading. The point of the log isn't to store corrections, it's to convert them: every lesson is meant to become a mechanism, and once it does it no longer loads into context, so the log gets cheaper to carry the more you use it.

Context survives compaction. Before the conversation gets summarized away, a hook (precompact_dump_plan.sh) dumps the plan to disk and re-reads it after, not from memory.

None of these are about the model. All of them are about the structure around it.

6. Audit it, or it does nothing

A mechanism you don't audit is indistinguishable from no mechanism. Two cases from my own system.

I wrote a hook to enforce self-critique (interrogate_enforce.py) and never registered it. For a week it fired zero times, dead code I'd checked off as done. Checkpoint 2 failed silently.

Same week, the correction-log hook above scanned the transcript for “correction signals,” but tool output was stored as the same type as my typed messages, so it matched files it had read into itself and accused me of corrections I never made. Running, producing garbage. Checkpoint 3 failed silently.

Verify a mechanism is wired and live, not that it exists. “I added the rule” is the answer that gets you hurt.

7. Build your own

Inside-out, each step paying off immediately:

  1. Learning loop first. A correction log plus a hook that won't end a turn until the correction is written. Get corrections to settle.
  2. Then the gate. Split free-write from canonical; cheap and reversible runs full speed, irreversible stops for you. This is what lets you take your hands off.
  3. Then memory. Sort rules by decay, sink the ones that must not die into hooks.
  4. Audit. Verify each mechanism fires, not that it exists.
  5. Stay lean. Ask if a layer was added for today's model and will be dead weight next version. If so, tear it out.

The signal under the noise: the model is rented, the structure around it is yours. Stop tuning the layer being commoditized. Build the one that isn't.