Part 1: How AI agents keep track of a conversation and what to do when it gets too long, with hands-on Python code