Examples
Short-term Memory
Manage ephemeral, session-scoped context with automatic expiration.
Storage Module
Scenario: Tracking current conversation state
When to Use
Use short-term memory as a "scratchpad" or RAM for the current session. Data here is temporary and meant to expire. Perfect for:
- Current conversation topic
- User's immediate mood or sentiment
- Drafting responses or holding intermediate reasoning steps
Key Operations
add()Add key-value to buffer with TTL
get()Retrieve value by key
Code Example
Here we buffer the user's current mood and topic. Note the ttl_seconds - this data will auto-delete after 1 hour.
Key Takeaways
- Short-term memory is key-value based, making it fast and direct.
- TTL (Time To Live) ensures you don't clutter storage with stale context like "user is typing...".
- It complements Semantic/Episodic memory by handling "right now" vs "forever".