Home/Agentic AI/Memory Types/Short-Term Memory

Memory Types

Understand how AI agents store, retrieve, and manage information across different memory systems

Short-Term Memory: The Context Window

In AI agents, short-term memory is implemented via the context windowβ€”the recent conversation history sent with each request. It's fast, immediately accessible, but severely limited by token count.

Interactive: Context Window Explorer

Adjust window size and see how it affects conversation capacity

4,000 tokens
1K32K128K
5 messages
12550
Window CapacityStandard
Tokens per Message
~800 tokens
Total Capacity
4,000 tokens
Can Store
~40 messages

Assessment:

Good for short interactions

Current Context Window Contents:

Message #5800 tokens
πŸ‘€ User: What are the different types of memory?
Message #4800 tokens
πŸ€– Agent: Memory types include working, episodic, semantic...
Message #3800 tokens
πŸ‘€ User: Can you explain working memory in detail?
Message #2800 tokens
πŸ€– Agent: Working memory is temporary storage for...
Message #1800 tokens
πŸ‘€ User: Previous interaction content (1 turns ago)

Short-Term Memory Strategies

πŸ”„

Sliding Window

Keep only the N most recent messages. Simple but loses older context.

messages = messages[-N:]
πŸ“

Summarization

Compress old messages into summaries. Preserves key info while reducing tokens.

summary = summarize(old_messages)
🎯

Importance Filtering

Keep important messages regardless of age. Drop mundane exchanges.

if importance_score > threshold: keep
🧩

Hybrid Approach

Combine strategies: recent messages + important older ones + summary.

context = recent + important + summary

Context Window Limitations

πŸ’Έ

Cost Scales with Size

Every token in context is processed and charged for. Large windows = expensive queries, especially with many requests.

🐌

Latency Increases

More tokens to process = longer response times. 128K context feels noticeably slower than 4K.

🧹

Eventually Fills Up

Even large windows have limits. Long conversations or document processing will eventually exceed capacity and require truncation.

πŸ”„

Lost When Session Ends

Context window is stateless. When the conversation ends, everything is forgotten unless explicitly saved to long-term storage.