Giving Your AI Agent a Memory File It Can Read and Write
A simple `memory.md` the agent can update lets it remember across runs without a database.
7 min · Reviewed 2026
The big idea
Agents forget everything between runs by default. The cheapest fix is a single file the agent can read and append to — no vector DB, no infrastructure, just a Markdown scratchpad.
Some examples
Claude with a memory.md tool remembers your name on the third session even though it's a stateless API.
An agent appends 'user prefers dark mode' to its memory after you say so once.
ChatGPT given a memory file recalls last week's project context when you start a new chat.
A coding agent writes 'project uses pnpm not npm' to memory and stops suggesting npm commands.
Try it!
Add a readMemory and appendMemory tool to any agent. Tell it to remember three things across two sessions.
End-of-lesson check
15 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-builders-agentic-ai-agent-memory-file-r9a8-teen
What happens to an AI agent's information by default when you start a new conversation or session?
The agent forgets everything from previous sessions
The agent only forgets minor details
The agent keeps all information but in a different format
The agent remembers everything but cannot use it
What is the simplest infrastructure-free solution for giving an AI agent memory across sessions?
A cloud storage service with an API
A vector database with embeddings
A dedicated SQL database server
A simple text file like memory.md that the agent can read and write
Why is memory.md called the 'duct-tape MVP' of agent memory?
It's the most advanced and professional solution available
It requires special expensive hardware to function
It's a quick, simple fix that works surprisingly well before needing fancier solutions
It was the first memory solution ever invented for AI
What two capabilities must a memory system have for an agent to remember information across sessions?
Format the memory file and validate its contents
Delete old memory and encrypt new memory
Read existing memory and append new information to it
Copy memory between files and compress it
If an AI agent learns during a conversation that the user prefers dark mode, where should it store this information?
In the agent's code as a hardcoded variable
In a temporary cache that clears when the session ends
In the agent's system prompt only
In the memory.md file so it's available in future sessions
What does the term 'persistence' mean when discussing AI agent memory?
The ability to retain information across different sessions or runs
The speed at which information can be retrieved
The total amount of information that can be stored
The security level of stored information
Which tool would you add to an agent to let it store new facts it learns during conversation?
appendMemory (or writeMemory) to add new information
formatMemory to clean up the file
deleteMemory to remove old information
readMemory to recall previous information
If an agent needs to recall what happened in a previous conversation, what should it do first?
Search the internet for relevant facts
Make guesses based on context
Read the memory.md file to access stored information
Ask the user to repeat everything
Why might a developer choose memory.md over a database for simple agent memory needs?
It stores data more quickly than databases
It can hold more information than databases
It provides better security than databases
It requires no database infrastructure—just a plain text file
What 'state' does a simple memory file help an agent maintain?
Information about the user, project, and preferences that persists over time
The network connection status
The error and exception state
The current computational processing state
After two separate sessions with memory tools, what should an agent be able to do?
Predict what will happen in the next session
Only function in the most recent session
Recall information learned in the first session during the second session
Store more information than a database can handle
What is the minimum number of distinct memory tools needed for basic cross-session memory?
Four tools for maximum memory functionality
Three tools for reading, writing, and deleting
One tool that does everything
Two tools—one to read and one to write/append
Why is having 'goldfish-level memory' (remembering briefly) better than zero memory for an AI agent?
Goldfish are actually very intelligent creatures
Even brief retention allows continuity and context across interactions
It makes the agent appear more human
It costs less to implement than real memory
In the example from the lesson, what specific information did Claude remember across sessions using memory.md?
Its own source code
The user's name from previous sessions
Technical documentation it had read
The entire conversation word-for-word
What type of file is memory.md?
An encrypted file that needs a password
A video or image file
A simple Markdown text file readable by any text editor