Three ways to carry state
Once your loop runs past a few iterations, the prompt is mostly prior turns. Three ways to manage that:
- Full history — keep every turn verbatim. Highest fidelity, fastest to bloat. Fine for short loops (≤5 turns).
- Sliding window — keep the last K turns plus the system prompt. Loses early context. Use when the task is local (debugging one file).
- Scratchpad — keep one mutable summary the model rewrites each turn. Best for long multi-step work; trades fidelity for focus.
Most production loops use a hybrid: system prompt + user request + last K turns + a scratchpad of decisions. Don't pick one philosophy; pick what each piece of state earns its keep at.
