Context Window Fill and Drift¶
Run the Context Window Fill and Drift MicroSim Fullscreen
About This MicroSim¶
Early in a long session, the builder types a rule: "A check that didn't run is never counted as passed." The sim plays the session turn by turn and draws the context window as a fill meter. Each turn is a block. The block that holds the rule is gold.
When adding a turn would overflow the window, the harness runs compaction. It removes the oldest chat turns and puts one short summary block in their place, until the window is back under 70 percent full. The summary keeps each turn's goal and drops any rule text. Turn 0 blocks, the harness instructions and the project instruction file, are never removed.
You predict at three checkpoints whether the agent can still see the rule. Then you pick the explanation that fits. After that, you can change the window size and where the rule lives, and replay the session.
The session, its token counts and the summary behavior are illustrative. Compaction behavior varies by agent.
How to Use¶
- Press Play turns 0 to 5 and watch the meter fill. The rule is marked in gold.
- At checkpoint 1, press Can see the rule or Can't see the rule. Read the feedback.
- Press Continue to turn 12. The sim pauses before turn 12. Predict again, then watch compaction run.
- Checkpoint 3 replays the session with the rule in the instruction file. Predict once more.
- Pick the explanation, A to D, with the buttons or by clicking a statement.
- Press Explore on your own. Move the Window size slider, change Rule in, and press Replay session.
- Hover over any block in the meter or any row in the turn list for details.
Mastery is 3 of 3 predictions correct and the right explanation chosen.
Iframe Embed Code¶
You can add this MicroSim to any web page by adding this to your HTML:
<iframe src="https://arunbatchu.github.io/good-enough-engineering/sims/context-window-drift/main.html"
height="601px"
width="100%"
scrolling="no"></iframe>
Lesson Plan¶
Learning Objective¶
The learner will explain why a rule typed early in a chat can drop out of an agent's context in a long session while the same rule in a project instruction file stays, by predicting at three checkpoints whether the agent can still see the rule.
Grade Level¶
Adult professional (Good Enough Engineering)
Duration¶
10-15 minutes
Prerequisites¶
- Token
- Context window
- Compaction
- Context drift
- Project instruction file
Activities¶
- Exploration (5 min): Before pressing Play, write down whether you expect the rule to survive the session.
- Guided Practice (5 min): Work through the three checkpoints and the explanation question.
- Assessment (5 min): In free exploration, find the smallest window where the rule in chat survives the whole session. Explain why that still doesn't make the chat a safe home for the rule.
Assessment¶
- 3 of 3 predictions correct and explanation B chosen.
- The learner can explain why the instruction file survives compaction and a chat turn does not.
Common Misconceptions¶
- Anything said in the session stays available until the session ends.
- A bigger window means drift can't happen.
- The agent will say when it has forgotten something.
References¶
- Chapter 4: AI Coding Agents - the section "Context Drift."
- Context windows - Anthropic documentation on how a model's context window fills over a conversation.