S
Saurav Danej
90-Day AI/ML LinkedIn Content System
← All days
76
Day 76 of 90Agents

Memory in agents — short, long, working

POST 1 of 5 MorningAgentsConcept

Three kinds of agent memory

Memory in agents isn't one thing.

- Working memory — current conversation. Lives in the messages array.
- Short-term memory — recent sessions, user preferences, active tasks. Often a small DB or cache.
- Long-term memory — facts, preferences, decisions that should persist forever. Vector store or structured DB.

Different storage, different lifecycles, different recall mechanisms. Mixing them is how 'amnesia bugs' happen.
#Agents#LLM#AI#LangGraph#100DaysOfCode#AgentMemory
POST 2 of 5 MiddayAgentsDeep dive

Summarise as you go — survive token limits

Long conversations bust context limits. The fix isn't 'bigger context'. It's compression.

Every N turns:
1. Summarise old turns into a short paragraph.
2. Replace old turns with the summary.
3. Keep the most-recent turns verbatim.

Frameworks call this ConversationSummaryBufferMemory or similar. The agent retains the gist of long sessions without paying long-context tokens.

For really long sessions, keep the summary in long-term memory and rebuild context per session.
#Agents#LLM#AI#LangGraph#100DaysOfCode#AgentMemory
POST 3 of 5 AfternoonAgentsCode

Rolling-summary memory in 20 lines

Keep last K turns verbatim. Older turns get summarised into a single 'summary' message at the front. Re-summarise when older + summary exceeds budget.

Simple, robust, framework-agnostic. Plugs into any LLM API.
#Agents#LLM#AI#LangGraph#100DaysOfCode#Python
POST 4 of 5 EveningAgentsTip

Don't store secrets in long-term memory

Agents have a habit of writing 'remember user said password is X' into memory. Don't.

My rule:
- Long-term memory stores user preferences and decisions, not credentials
- Filter out PII / secrets before writing to vector store
- Tag memories with sensitivity; refuse to retrieve when context is wrong

Memory leaks across sessions feel benign until they aren't. Ship with redaction from day one.
#Agents#LLM#AI#LangGraph#100DaysOfCode#Security
POST 5 of 5 NightAgentsRecap

Day 76 — agents that remember (sensibly)

Day 76 done.

- 3 kinds of memory
- Rolling summary survives token limits
- 20-line implementation
- Redact before persisting

Tomorrow (Day 77): the agent failure modes I've seen most. Then we close week 11.
#Agents#LLM#AI#LangGraph#100DaysOfCode#AgentMemory