Free & open · no paywall, ever

IntegrAuth Academy

Identity, security and practical AI — free, from zero. Byte-sized lessons, real diagrams, hands-on labs, zero fluff. Two programs, each with its own exam and certificate.

20 tracks 241 lessons 242 hands-on labs 230+ diagrams 100% free

English is hard? Your browser can translate this page into Tamil, Telugu, Kannada, Malayalam or Hindi. Tech words stay in English so you learn the real names.

How?
  • Chrome on phone: ⋮ menu → Translate
  • Chrome on computer: right-click → Translate to …
  • Edge: the translate icon in the address bar
Practical AI Track 2 · Working with AI
0/75 lessons read
WORKING WITH AI · LESSON 8

Context and memory

Every Monday, Priya explains the same rules to her AI again. Every Monday, it has forgotten them. Your goal: choose what the AI sees, and what it keeps.

🧪 Interactive lab — enable JavaScript to play with this one.

One context window (a fixed budget of tokens)instructionstoolsmemoryretrieved docshistoryquestionanswer roomstable → first (cache-friendly)changing → lastLeft out on purposeunrelated chat logwhole product catalogold raw tool output
Pack for the task. Everything must fit, the answer too. Stable parts go first. The new question goes last.
Key points
  • The AI only uses what is in front of it right now.
  • More text is not better. It costs more and can mislead.
  • Memory is saved text that is put back in front of the AI.
  • A rule that must last goes in a file, not only in the chat.

What the AI sees

Each time the AI answers, it reads one block of text, its context window. It holds your rules, documents, the chat so far and room for the answer.

Think of packing a small bag for a trip. You choose what goes in, and in what order. For AI, this is context engineering. For each item, you can include it in full, summarize it, point to it, or leave it out. Put stable parts first. Put things that change, like your question, last.

Short-term and long-term memory

The chat so far is the AI's short-term memory. It lives in the window. When the session ends, it is gone. Long-term memory is text stored outside the model. The app loads it back into the window later. The model itself does not change when it "remembers" you.

Saved memory can go wrong. An old fact stays until someone deletes it. A rule from a web page can steer every later chat. Clean up Priya's saved memories now.

🧪 Interactive lab — enable JavaScript to play with this one.

Go deeper: why more is not better

Big windows tempt people to paste in everything. There are 3 reasons not to.

  • Cost and speed. You pay for every token on every call. The AI must read all of it each time (Cost, limits and caching).
  • Lost in the middle. Models use the start and the end of a long text best. Things in the middle get less attention. This is called lost in the middle. Answers slowly get worse as the text grows.
  • Distraction. Some text looks useful but is not. An old policy or a similar customer's case can pull the answer the wrong way.

Include an item in full when the exact words matter. To point to an item, give a file name or a link. The AI opens it only if it needs it. Stable parts first also help prompt caching. With long documents, many providers suggest this order: documents first, your question at the end.

Go deeper: when the window fills up

Long sessions reach the limit. Many tools then write a summary of the chat so far and go on from it. This is compaction. Some tools do it on their own, sometimes without telling you. In Claude Code, you can also type /compact.

Compaction keeps a long task going. But a summary loses detail. The exact words of an early rule may not survive. Claude Code reads its project instruction file again after compaction. A rule you only said in chat may be lost. So anything that must last goes in a file.

Go deeper: instruction files

An instruction file is a plain text file. The tool loads it at the start of every session. AGENTS.md is an open format for AI coding tools. The Agentic AI Foundation hosts it. As of October 2026, many tools read it, like OpenAI's Codex, GitHub Copilot and Cursor. Google's Antigravity CLI reads it too. Claude Code has its own file, CLAUDE.md. It also reads AGENTS.md when a project has no CLAUDE.md.

Good files are short. Say how to build and test, the house rules, what never to do, and where things live.

These files are context, not a lock. The model usually follows them, but not always. A hard rule like "never push to main" also belongs in the tool's permissions or in automatic checks.

Go deeper: kinds of memory and who can see them
KindWhere it livesWho writes it
The chatThe context windowYou and the AI
Instruction fileA file in your projectYou, sometimes the AI
Saved memoriesThe provider's serversThe assistant, with your controls
Search memoryA store you can searchThe app

Search memory loads only the few notes that match your request, like Search by meaning: embeddings and RAG. ChatGPT and Claude both have a memory feature across chats. You can view, edit or delete memories, or switch it off. By default, a temporary chat does not read memory or add to it.

Who can see it? The provider stores it, and deleting can take time. Admins may see it on business plans. Anyone with the project can read its instruction file. A bad rule can even be saved from a web page (prompt injection).

Watch out

Never put passwords, API keys or customers' personal data in memory or instruction files. They are loaded into every later session and sent to the provider each time.

🧪 Try it free

Open your chat assistant's memory settings. Delete anything you would not want a coworker to see.