
Why History Matters
Enterprise-grade chatbots—like ChatGPT—depend on stored context to resume conversations seamlessly. Since LLMs are inherently stateless, each new query loses all prior session details unless you explicitly include them.
If you omit previous messages from the input, the model treats every prompt in isolation. This can lead to incoherent replies or hallucinations.

Memory Types
LLM apps generally leverage two forms of memory:| Memory Type | Scope | Persistence |
|---|---|---|
| Short-term | Single session | Volatile (stored in RAM) |
| Long-term | Cross sessions | Durable (persisted in external store) |

Short-Term Memory
- Lives only in RAM during a session.
- Ideal for quick back-and-forth where data retention ends when the session closes.
Long-Term Memory
- Persisted in an external database.
- Ensures conversations can resume even after days or weeks.
While this lesson uses Redis for demonstration—thanks to its speed and simplicity—you can apply the same patterns to any persistent store, such as SQLite, PostgreSQL, or vector databases.