Minimal Memory Example
The following flow stores a preference in one session, writes that session to long-term memory, and recalls the information from a new session.ShortTermMemorystores the event history forsession-1.SaveSessionToLongTermMemorywrites that conversation to long-term memory.- The new
session-2still uses the sameuserID, so the agent can retrieve previous information.
VeADK Backends
In-memory storage is useful for debugging. Production deployments can useNewLongTermMemoryService with Viking, Mem0, Redis, or OpenSearch.
The optional third argument of
NewLongTermMemoryService(backend, config, topK...) controls retrieval count. The default is 5.
Auto Save
EnableAutoSaveSession when you want each run to write newly added session events to long-term memory.
MemoryAutoSavePolicy when more event types must be saved:
MemoryAutoSaveDefault keeps user text only. MemoryAutoSaveAll keeps more roles and event types, including assistant content, tool events, and media-related content. Production systems should usually start with the default policy and expand it deliberately.
Suitable content
- Stable user preferences.
- Confirmed project background and terminology.
- Reusable troubleshooting or task conclusions.
Short-Term Session versus Long-Term Memory
Do not write every conversation into long-term memory blindly. Store information only when it is stable, confirmed, and likely to be useful later.