Skip to content

Backends

Internal backend adapters for configured memory runtimes.

BaseMemoryBackendAdapter

Bases: ABC

Abstract adapter interface for one internal memory backend.

Attributes:

Name Type Description
backend_key str

Stable internal identifier for the backend implementation.

build_configured_client(*, config, instruction=None, timeout_sec=30) abstractmethod

Build one configured memory client for this backend.

Parameters:

Name Type Description Default
config dict[str, Any] | MemoryManagerConfig

Memory configuration candidate.

required
instruction str | None

Optional instruction override. Defaults to None.

None
timeout_sec int

Request timeout in seconds. Defaults to 30.

30

Returns:

Name Type Description
BaseMemoryClient BaseMemoryClient

Concrete client instance for the selected backend.

can_handle_config(config) abstractmethod

Determine whether this adapter can handle one config object or payload.

Parameters:

Name Type Description Default
config dict[str, Any] | MemoryManagerConfig

Memory configuration candidate.

required

Returns:

Name Type Description
bool bool

True if this adapter can build a runtime for the given config.

Mem0BackendAdapter

Bases: BaseMemoryBackendAdapter

Backend adapter that compiles config payloads into Mem0 runtime clients.

build_configured_client(*, config, instruction=None, timeout_sec=30)

Build one Mem0 SDK client from the given config input.

Parameters:

Name Type Description Default
config dict[str, Any] | MemoryManagerConfig

Memory configuration candidate.

required
instruction str | None

Optional instruction override. Defaults to None.

None
timeout_sec int

Request timeout in seconds. Defaults to 30.

30

Returns:

Name Type Description
BaseMemoryClient BaseMemoryClient

Concrete Mem0SDKClient instance.

Raises:

Type Description
ValueError

If the config is unsupported by this adapter.

can_handle_config(config)

Determine whether this adapter can handle one config object or payload.

Parameters:

Name Type Description Default
config dict[str, Any] | MemoryManagerConfig

Memory configuration candidate.

required

Returns:

Name Type Description
bool bool

True when the config is compatible with the Mem0 backend.

build_configured_memory_client(*, config, instruction=None, timeout_sec=30)

Build one configured memory client using the resolved backend adapter.

Parameters:

Name Type Description Default
config dict[str, Any] | MemoryManagerConfig

Memory configuration candidate.

required
instruction str | None

Optional instruction override. Defaults to None.

None
timeout_sec int

Request timeout in seconds. Defaults to 30.

30

Returns:

Name Type Description
BaseMemoryClient BaseMemoryClient

Concrete client instance created by the selected adapter.

resolve_config_backend_adapter(config)

Resolve one backend adapter for the given config object or payload.

Parameters:

Name Type Description Default
config dict[str, Any] | MemoryManagerConfig

Memory configuration candidate.

required

Returns:

Name Type Description
BaseMemoryBackendAdapter BaseMemoryBackendAdapter

Matching backend adapter.

Raises:

Type Description
ValueError

If no registered backend adapter can handle the config.