How does memory work in an AI agent?
The context window
The most immediate memory is the context window, the text the model can see on the current turn. It is limited in size, so long tasks need a way to carry forward only what matters rather than everything that has happened.
Longer-term memory
For information that should persist across sessions, agents use external stores such as a database or a vector index that can be searched and read back into the context when relevant. This is retrieval, and it keeps the live context small while still giving the agent access to a larger body of facts.
Keeping memory honest
Memory can carry forward mistakes as easily as facts. Separating verified records from the agent working notes, and letting a person correct stored information, reduces the risk that an early error becomes a permanent assumption.
This article is general educational information, not technical, legal or business advice. AI agent capabilities, tools and costs change quickly, so verify current details and check important output before relying on it.
← All agent guides