if history reaches 4000 tokens api will not work you either have to delete full history or some older message manually what you can do is add timestamp to messages and delete them after a certain amout of time so we can never reach 4000 tokens limit