Skip to main content
Long-term memory keeps user preferences, task conclusions, and reusable facts across sessions. VeADK Go provides a unified entry point on top of ADK MemoryService and includes examples for local, Viking, Mem0, and related backends.

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.
Key points:
  1. ShortTermMemory stores the event history for session-1.
  2. SaveSessionToLongTermMemory writes that conversation to long-term memory.
  3. The new session-2 still uses the same userID, so the agent can retrieve previous information.

VeADK Backends

In-memory storage is useful for debugging. Production deployments can use NewLongTermMemoryService with Viking, Mem0, Redis, or OpenSearch.
Available backends: The optional third argument of NewLongTermMemoryService(backend, config, topK...) controls retrieval count. The default is 5.

Auto Save

Enable AutoSaveSession when you want each run to write newly added session events to long-term memory.
App launchers support the same option:
By default, auto-save keeps user text only. Use 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.

Troubleshooting

Last modified on October 20, 2026