Nice explanation. I think one distinction that becomes important in real AI Agent Systems is that memory and RAG are related, but not the same thing.
RAG helps retrieve useful external knowledge.
Memory needs to preserve continuity, state, preferences, prior actions, and sometimes evidence of what actually happened.
For Production Agents, I think memory also needs governance:
Without that layer, memory can become another form of context pollution.