Skip to main content
ValkeyDb is a class that implements the Db interface using Valkey as the backend storage system. It provides high-performance, distributed storage for agent sessions with support for JSON data types and schema versioning.
ParameterTypeDefaultDescription
idOptional[str]-The ID of the database instance. UUID by default.
valkey_clientOptional[Union[GlideClient, GlideClusterClient]]-Pre-configured Valkey GLIDE client. If not provided a new client will be created.
hoststr"localhost"Valkey server host.
portint6379Valkey server port.
database_idOptional[int]-Logical database index (e.g. 0-15).
usernameOptional[str]-Username for authentication.
passwordOptional[str]-Password for authentication.
use_tlsboolFalseEnable TLS encryption.
request_timeoutOptional[int]-Milliseconds to wait for a request to complete. If unset, the GLIDE client default (250 ms) applies.
db_prefixstr"agno"Prefix for all Valkey keys.
client_namestr"agno_db_client"Connection name, visible in CLIENT LIST.
expireOptional[int]-TTL for Valkey keys in seconds.
session_tableOptional[str]-Name of the table to store sessions.
memory_tableOptional[str]-Name of the table to store memories.
metrics_tableOptional[str]-Name of the table to store metrics.
eval_tableOptional[str]-Name of the table to store evaluation runs.
knowledge_tableOptional[str]-Name of the table to store knowledge documents.
traces_tableOptional[str]-Name of the table to store traces.
spans_tableOptional[str]-Name of the table to store spans.
learnings_tableOptional[str]-Name of the table to store learnings.

Methods

upsert_sessions

Bulk upsert multiple sessions for improved performance on large datasets. Parameters:
  • sessions (List[Session]): List of sessions to upsert
  • deserialize (Optional[bool]): Whether to deserialize the sessions. Defaults to True
  • preserve_updated_at (bool): Whether to keep the sessions' existing updated_at timestamps. Defaults to False
Returns: List[Union[Session, Dict[str, Any]]]

upsert_memories

Bulk upsert multiple memories for improved performance on large datasets. Parameters:
  • memories (List[UserMemory]): List of memories to upsert
  • deserialize (Optional[bool]): Whether to deserialize the memories. Defaults to True
  • preserve_updated_at (bool): Whether to keep the memories' existing updated_at timestamps. Defaults to False
Returns: List[Union[UserMemory, Dict[str, Any]]]