Keeping state across steps and sessions.
Made for you now: slide lessons from basics to production, usually with code and a quiz. See a finished one
An LLM remembers nothing between calls. Anything that looks like memory is text your application puts back into the prompt.
Short-term memory is the running conversation, trimmed or summarised to fit the context window. Long-term memory is stored outside the model, such as user preferences or past facts, and retrieved when relevant, usually with the same embedding search used for RAG.
Store durable facts, not whole transcripts. Record when and where each memory came from, let users view and delete them, and expire stale ones. Never store secrets or personal data you do not need.
Step 1
Conversation turn
User and assistant messages.
Step 2
Extract facts
Pick durable items worth keeping.
Step 3
Store
Database or vector store with source and time.
Step 4
Retrieve next turn
Fetch relevant memories for the new query.
Step 5
Inject into prompt
Add them to the context, within budget.
↺ Every turn can write new memories