Go to Settings > Storage. Tick "Delete old messages" and in the drop down menu below, set the limit on the number of messages each conversation can have.