Agent Memory: What to Keep and What to Forget
My agent forgot my name after four messages. When I let it remember everything, it remembered my card number too.
Video #23 ยท AI agents and MCP
Steps in the video
Files
- agent.py (13 lines)
- chat.py (65 lines)
- extract.py (21 lines)
- guard.py (9 lines)
- memory.py (45 lines)
Tested with
Python 3.12.15 | ollama==0.6.3
What this does not show
One small local model, one made-up ten-message chat and six questions written by the author, one run. Scoring is strict; the curated mode's one miss is a hedged answer, not a lost memory. No size cap or eviction is built. The guard is two patterns and is not enough for real sensitive data. The card number is a standard test number.
Sources
Learning IT by Example.