Memory · Software component
Sliding-Window History Truncator
Software componentMemoryCognition & Memoryarc:SlidingWindowHistoryTruncator
A context window manager that retains only the most recent N items of a history field, discarding older ones.
Responsibility. Keeps only the last N history items in state.
Also known as: keep_last_n operator, Maximum history limit, ConversationBufferWindowMemory, Blind context truncation, Truncation, Rolling buffer
Variant of Context Window Manager abstract
When to choose. Choose as the simplest bound when losing early conversation detail is acceptable.
Relationships
is configured by structural
alternative to variability
Design guidance
- SHOULD be expressed as a reducer on the state schema so pruning happens automatically on every update.
- SHOULD NOT be used where early turns establish account details, preferences or constraints that later turns depend on.
Quantitative guidance
As stated by the sources; verify before use.
- Example bound: keep only the last 15 conversation turns (Ch1.6).
- Truncation saving ~20% of token cost often increases hallucination rates by 50%+ (Ch3.10).
- Truncating the oldest conversation turns saves ~20-40% of tokens (Ch5.9).
Classification
- Patterns
- Sliding window
- Technologies
- LangGraph state annotationsLangChain
- Quality attributes
- Maintainability (ISO/IEC 25010)
- Risks mitigated
- Context overflow
Sources
- Ch1.6: T. Nguyen, "Stateful Orchestration - Pitfalls, Integration, and Synthesis," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 1.6. ISBN: 9798244538229.
- Ch2.3: T. Nguyen, "LangChain Sequential Frameworks," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 2.3. ISBN: 9798244538229.
- Ch3.10: T. Nguyen, "Efficiency Metrics," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 3.10. ISBN: 9798244538229.
- Ch5.9: T. Nguyen, "Working Memory," in Mastering Agentic AI Systems: Guide for the NVIDIA NCP-AAI Exam, 1st ed. 2026, ch. 5.9. ISBN: 9798244538229.
- Ref5.04: C. Stryker, "What is AI agent memory?," IBM Think. Accessed: Sep. 27, 2026. [Online]. Available: https://www.ibm.com/think/topics/ai-agent-memory