๐งชTDD Challengeยทbeginnerยทโฑ๏ธ 20โ35mยทโญ 125 XP
M-054Build a Sliding Window Memory Buffer
Description
Nebula Corp's chatbot forgets everything after each message. Users are frustrated because they have to repeat context constantly. Implement a sliding window memory buffer that stores the last N messages and includes them in every LLM call. The buffer should handle adding messages, retrieving context, and automatically trimming when it exceeds the maximum size.
Test Cases (3)
Stores messages
Adding a message increases size
Input:testStoreMessages()
Expected:1
Sliding window trims
Buffer trims to max size
Input:testSlidingWindow()
Expected:4
Context includes system prompt
Context starts with system message
Input:testContextPrompt()
Expected:CONTAINS:system
Related Lessons
Click Run / Check to validate your solution