Short-Term Memory
Per-session conversation history stored in
AgentSession. Tracks all messages, roles, and metadata for the active context window.Long-Term Memory
Persistent vector storage via
AgentrySimpleMem and LanceDB. Survives process restarts and can be shared across sessions.Architecture
The two layers are independently managed but both feed the agent’s LLM context at inference time:How the Two Layers Work Together
User message arrives
The agent receives the user message and appends it to the active
AgentSession message list.Long-term retrieval runs
If
memory=True, AgentrySimpleMem.on_user_message() is called. It performs a fast embedding-based semantic search against the LanceDB table and returns relevant memory strings to inject into the LLM context.LLM is called with full context
The LLM receives the full session message history (short-term) augmented with any retrieved memory snippets (long-term).
Key Behaviors
Short-term memory is always available for any active session. Long-term memory requires
memory=True on agent construction and a running Ollama embedding service.| Behavior | Short-Term | Long-Term |
|---|---|---|
| Scope | Single session | Configurable (per-session or per-user) |
| Persistence | In-process only | Survives restarts (LanceDB on disk) |
| Retrieval | Full history in order | Top-K semantic similarity |
| Filtering | None — all messages kept | Score-based; small talk is dropped |
| Enabled by default | Yes | No — requires memory=True |
The AgentrySimpleMem Class
AgentrySimpleMem is the primary interface for long-term memory. It lives at logicore.simplemem.AgentrySimpleMem and is instantiated automatically by Agent when memory=True.
When to Use Each Type
- Short-Term Only
- With Long-Term Memory
Use short-term memory alone when:
- The conversation is self-contained within a single session
- You don’t need recall across process restarts
- You want the simplest possible setup
Next Steps
Short-Term Memory
Session history,
AgentSession, context compression, and SessionManager.Long-Term Memory
The LanceDB storage pipeline, scoring logic, and retrieval flow.
SimpleMem Integration
Full
AgentrySimpleMem API reference and configuration options.