Sliding Window
Retain only the most recent N conversation turns in the agent's context. Oldest turns are dropped entirely. This caps the prompt size at a fixed bound regardless of session length.
Trade-offs
- Pros: cheap, deterministic, easy to implement.
- Cons: loses early decisions and long-range dependencies; fragile on long debugging or refactoring tasks where the original goal or constraints were stated at the start.
When to Use
Best as a fallback or combined with summarization. A pure sliding window is usually insufficient for coding agents working on multi-file tasks.
See Also
- Rolling Summarization — combine with sliding window to preserve state from dropped turns.
- Compaction — sliding window is one of several compaction strategies.
Tools
- LangChain ConversationBufferWindowMemory — keeps only the last K interactions in the buffer.