# Stateless

The model remembers nothing between calls. Each request starts from a blank slate.

AI developers · Part 01: LLM basics · Card 6 of 10 · Last updated 2026-10-13

## Analogy

A REST API with no session cookie. It greets you like a stranger every time, no matter how many times you've met.

## Code example

`stateless.ts`

```typescript
// Call 2 must carry the whole conversation again
const messages = [
  { role: "user", content: "My name is Faisal" },
  { role: "assistant", content: "Nice to meet you, Faisal!" },
  { role: "user", content: "What's my name?" },
];
```

## In an agent

"Memory" in an agent means your code stores the messages and resends them on every call.

## Practice

### Interview questions

**How do you handle memory?**

- Short-term memory is the message history, trimmed or summarized near the context limit.
- Long-term facts go to a database and are retrieved when relevant.
- For multi-step tasks, LangGraph checkpoints in Postgres hold the working state.

## Questions people ask

### Does ChatGPT remember my conversation between API calls?

The API does not. Every request starts from a blank slate, and the model only sees what you send in that request. Chat apps feel like they remember because the app stores the conversation and sends it again with every new message. Your own code has to do the same.

### How do agents have memory if the model is stateless?

Your code keeps the memory. It stores the messages array and resends it on every call, which is short-term memory. It can also save facts to a database for long-term memory, and save the agent's progress in a checkpointer. The model itself never stores anything between calls.

## Related concepts

- [Checkpointing](https://studyvisually.com/learn/tech/ai-developers/langchain-langgraph/checkpointing)
- [Short-term, long-term and working memory](https://studyvisually.com/learn/tech/ai-developers/production/memory-types)
- [LLM](https://studyvisually.com/learn/tech/ai-developers/llm-basics/llm)
- [Next-token prediction](https://studyvisually.com/learn/tech/ai-developers/llm-basics/next-token-prediction)

Web page: https://studyvisually.com/learn/tech/ai-developers/llm-basics/stateless
Study this card in the app: https://studyvisually.com/app/learn?category=ai-developers&card=stateless
