Skip to main content
The openviking long-term memory backend writes conversation messages to OpenViking user memory and retrieves entities, events, and preferences by user identity. It is available in VeADK 1.0.3 and later.
Runner.user_id is the end-user identifier that VeADK uses as the OpenViking peer_id for memory isolation. openviking_user_id is the OpenViking owner/context used to isolate memories for different applications or tenants within the same OpenViking service. The two are distinct concepts.

Example

The base installation includes openviking-sdk. Before running, provide an OpenViking service with user memory support and set DATABASE_OPENVIKING_URL, DATABASE_OPENVIKING_API_KEY, and DATABASE_OPENVIKING_USER_ID. Automatic and manual saves both send conversation content to that service; configure access and retention first

Parameters

LongTermMemory parameters

OpenViking backend parameters

By default, user_id becomes the peer ID and may contain only letters, digits, periods, underscores, @, and hyphens. Pass peer_id_resolver to customize this mapping. When openviking_user_id is not configured, VeADK checks DATABASE_OPENVIKING_USER_ID and falls back to default, emitting a warning. Set it explicitly for each application or tenant to avoid mixing memories from different applications under the same default path. When memory_policy is unset, VeADK sends no policy to OpenViking and the OpenViking service applies its official default. To explicitly control the extraction scope and isolation, pass a valid memory_policy whose structure follows the OpenViking session API. For example:
This example disables self-memory extraction and only extracts entities, events, and preferences from the counterparty; the actual accepted values and fields depend on what the OpenViking service supports.
Setting auto_save_session=True writes conversation data to an external OpenViking service. Confirm that data processing, access control, and retention meet your requirements before enabling it.

Environment variables

Customize user mapping

Multi-tenant applications can provide peer_id_resolver to combine the application and user into one isolation key:
The returned ID cannot be empty. It may contain only letters, digits, periods, underscores, @, and hyphens, and cannot be . or ... Changing the mapping after deployment leaves existing memories under the old peer path, so later retrievals may no longer find them.

Verify writes and retrieval

After configuring the dependencies and credentials on this page, run this standalone example. It saves user text and searches for that user directly without calling a conversation model
Results should contain the saved language preference. Managed services may extract memories asynchronously, so a completed write does not guarantee immediate retrieval. An empty result can also indicate permission, network, or service failure; check error logs and service records. The save method does not return a success Boolean
Last modified on September 19, 2026