Memory
LangBot Day 2: Giving Your Chatbot a Memory with Conversation History
reading time: 5 minutes
Recap: Yesterday we built LangBot — a 27-line CLI chatbot powered by ChatOpenAI. It works, but every message starts from scratch. Ask “What’s my name?” and it invents one. Remind it “My name is Alex” and ask again — it still guesses. Today we fix that.
The problem: amnesia mode
Try this in Day 1’s LangBot:
You: My favorite color is blue.
LangBot: That's a great choice! Blue is calming and versatile.
You: What did I just say my favorite color was?
LangBot: I'm not sure — you haven't mentioned a favorite color in this conversation.
Every call to llm.invoke() sends a single HumanMessage. The model has zero context from previous turns. For a real chatbot, this is a dealbreaker.