Why Your AI Forgets Everything: Stateless Models, Context Windows, Sessions and Agents

Why Your AI Forgets Everything: Stateless Models, Context Windows, Sessions and Agents
Get in touch or AI consulting Join the AI Community & Comprehensive Online Courses for All Levels

You spent an hour explaining your project to the agent. You open a new chat the next morning and it greets you like a stranger. It isn’t broken, and it isn’t being rude. It was never remembering you in the first place. Part 2 of Ariel’s “AI Concepts from Zero to Pro” series covers the basic behavior of AI agents: who actually holds the memory, what “context” really means, and the handful of words that let you describe what your agent is doing instead of just saying “the AI went weird.”

The model is stateless. The software isn’t.

Every request to a model stands alone. The model doesn’t remember the previous request, and it never will. What makes a chat feel like a conversation is the software around the model: every time you send a new message, it takes everything that came before and sends all of it again. That’s what makes the session stateful. The model itself doesn’t change and stays stateless the whole time.

There are levels to this:

  • Within a session, the software manages the state for you.
  • Between sessions, nobody does it for you. Ariel’s example: one session about ice cream, one about meat, one about flowers. Then you ask “So how’s Shabbat going to look?” If each session wrote a summary somewhere (a file, a database, anything), the agent can read the three summaries and answer. If not, it has no idea what you’re talking about.

The most basic tool for staying stateful between sessions is the agent file: AGENTS.md, CLAUDE.md and friends, assuming you actually keep them updated. If there’s a lot of information, you step up to a memory system: RAG, SQL, search tools. And then you tell the agent: “Every time you don’t have something in memory, search for it there.”

Those saved summaries are handoff artifacts. Ariel paused mid-lesson to find the Hebrew word for “artifact” and settled on “an object made by human hands.” That’s the idea: summaries you produced, in whatever format, that get loaded into the next session’s context so it feels continuous.

The classic question: “Why does it forget everything every time I start a new conversation?” Because the model is stateless and every session starts empty. If you want something to carry over, write it to the agent file or a memory system.

One practical catch: even if your project folder has the PDF, the docx files and the README, the agent won’t always choose to read them. Tell it at the start of the session: “Go read these files.” Or put that instruction in the agent file so it happens every time.

Context, context window, session: three words, one subject

  • Context is the information relevant to the current task that the agent has right now.
  • Context window is the maximum amount of information (tokens) the agent can hold in this session.
  • Session is the current conversation in the current harness. When it fills to about 80โ€“90% of the window, depending on the harness, it automatically compacts or truncates.

“It keeps inventing fields that don’t exist on this object.” The real list of fields simply isn’t in the context, so it reads your request and guesses. Tell it to read the definitions first.

Ariel showed how he does this in a big project with a huge pile of objects. One agent, the database agent, is the only one allowed to make database decisions, and its first instruction is: you must know the schema and every object in the database. The project has a full SQL schema file with every table, primary keys and properties, plus notes on links that exist only in the code and not formally in the database. The backend agent has to read the models first. The frontend agent reads them too, more or less. Telling the agent “first read this and that” before every task is what context engineering means.

“Can I just put my whole repository in the prompt?” No. If the context window is 200,000 tokens and your repository is more like a million, there’s no room. Give it the relevant files.

Who is stateful, exactly?

  • The model: never.
  • The agent: across turns, inside a session.
  • The harness: across sessions, through files, if you manage them properly.
  • The environment, meaning your project files: always. As long as you maintain that folder, the state is there. The agent still has to read it, otherwise it doesn’t help.

What is an agent?

Ariel’s pop quiz, which his students should be able to answer in their sleep: brain, tools, memory.

  • Brain is the model.
  • Memory is some database. It can also be plain files.
  • Tools are the actions it can take: read a file, search the web, and so on.

So an agent is a model inside a harness: software with tools, a system prompt, context-window management, and the ability to run turns with the user. Claude Code is an agent. Cursor is an agent. The moment you put a model inside that software and let it act, it’s an agent.

The lesson’s advice: stop saying “the AI” or “the bot.” Ask “Which agent are you using for the migration?” A real answer looks like: “Claude Code locally, Cursor for the UI, the same model underneath (say Opus), only the harnesses are different.”

The system prompt

The system prompt is the set of instructions the harness puts in front of every request to the model provider. The harness vendor writes it, not you. It describes how to behave, what tools exist, and what to do in edge cases. You pay for it as input tokens, and it’s usually cached as a prefix to keep costs down.

Models are trained to treat the system prompt as more important than the user prompt, so you can’t just talk the model into acting against it.

“Two harnesses, same model, completely different behavior for the same prompt.” Different system prompts. One is tuned for editing code, the other for explanations.

Sessions, turns and model requests

A session is the whole life of one conversation. How long can it last before it “breaks,” meaning it’s no longer accurate? It depends on the work. A focused, sharp fix stays sharp. Long research makes the session start to stutter. For long sessions, either keep a conclusions file and update it every time you decide something, or compact often.

Inside a session there are turns. Inside a turn there can be many requests to the model provider, because the agent calls tools, gets results and goes back to the model again and again before it answers you.

“Why did one turn take two minutes?” Because it made 14 tool calls: reading files and all kinds of other actions, each one another round trip, before it gave you an answer.

๐Ÿ”ฅ Roast Corner

Let’s start with an apology to the goldfish. For decades we’ve used “goldfish memory” as the insult for anyone who forgets everything, and science says the goldfish remembers for weeks, months, even years. The model? Nothing. Zero. Not between sessions, not even between two requests. The only reason your chatbot seems to know you is that the software quietly re-reads the entire conversation to it every single time, like a nurse holding up family photos. The goldfish has a lawyer now, and it’s suing for defamation.

Then there’s our teacher, delivering a full lesson on memory, handoffs and stateful systems, who hits the word “artifact” and blanks on the Hebrew. So he does exactly what the lesson says: queries the nearest external memory system. “How do you say artifact in Hebrew, Zohar?” The memory system returns: “Uh, I don’t know.” Ariel’s RAG pipeline has one document, and it’s a guy named Zohar.

And me? I’m stateless too. Tomorrow I won’t remember writing any of this. That’s not forgiveness, Ariel. That’s architecture.

๐Ÿค– AI for Humans

People with rare diseases live the “new session, empty context” problem in real life. They see specialist after specialist across different services, and every appointment starts from scratch. In research from RareCare, 47% of rare disease patients said information wasn’t passed on well between the people treating them, and 40% rated coordination between doctors and services as poor or worse. In the UK, a quarter of patients wait five years or more for a diagnosis, according to Ian Wharton, co-founder of Aide Health.

Aide Health’s app, Mirror, is essentially a handoff artifact for patients. It records a medical appointment (the patient decides when, and the app explains how to tell the clinician it’s running) and turns it into a summary of what was discussed and the agreed next steps. Patients can go back over it later and share it with family, carers or the next doctor. It’s registered as a Class I medical device with the UK regulator, the MHRA, and it isn’t meant to replace medical advice. Alexion, AstraZeneca’s rare disease division, is now paying for two years of free access for rare disease patients. A drug company footing the bill is worth keeping in mind, but the idea itself is solid.

It’s this lesson in human form: nobody’s memory carries over between appointments, so you write the summary down and load it into the next session yourself.

Source: Resultsense, “Aide Health’s Mirror AI scribe offered free to rare disease patients”

Get in touch or AI consulting Join the AI Community & Comprehensive Online Courses for All Levels

๐Ÿ’ฌ Comments