{
  "id": 9349760,
  "title": "Why Your AI Chatbot Forgets Everything — And How to Fix It",
  "url": "https://urgent.news/2026/09/23/why-your-ai-chatbot-forgets-everything-and-how-to-fix-it",
  "topic": "ai",
  "section": "AI",
  "published": "2026-09-23T14:30:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/shamprakash2000/why-your-ai-chatbot-forgets-everything-and-how-to-fix-it-26je"
  },
  "original_language": "en",
  "account": "The article explains why AI chatbots forget context between conversations and how to fix this limitation. When calling an API like the Gemini API, the model treats each call as independent, with no memory of previous messages. To enable the chatbot to remember context, the solution is to include all past messages in every API call. The author demonstrates this with a simple Java Spring API that stores conversation history in memory using a Map. Each user gets their own session ID, and the model's replies are added to the session's history. The code is straightforward and requires only basic Java knowledge.\n\nHowever, this in-memory approach has two significant drawbacks. First, the context is lost when the server restarts, losing all previous conversations. Second, all users share the same conversation history, which is impractical for multiple users interacting simultaneously. Additionally, long conversations can quickly exceed the model's token limit, limiting its ability to maintain context effectively.\n\nTo address these issues, the article recommends using a persistent database like PostgreSQL. The author suggests using Neon, a free, serverless PostgreSQL service that requires no setup. After creating a free Neon project and obtaining the connection string, the code can be updated to use Spring AI's JdbcChatMemoryRepository, which provides a more scalable, persistent solution for storing conversation history. By incorporating these changes, the chatbot can maintain context across sessions, support multiple users independently, and handle longer conversations without token limits.",
  "summary": "In the last article we built a working chat endpoint. Send a message, get a reply. It felt like magic. Then I tried to have an actual conversation. Me: \"My name is Sham.\" AI: \"Hi Sham! How can I help you?\" Me: \"What's my name?\" AI: \"I don't have access to personal information about you.\" The model had completely forgotten who I was. Not because it was broken — because of something fundamental…",
  "key_points": [
    "AI chatbots forget context between conversations due to independent API calls.",
    "In-memory solution stores conversation history in Java Spring API using Map.",
    "Persistent database like PostgreSQL solves context loss and scalability issues."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}