ADK.Memory.Store behaviour (ADK v0.0.1-alpha.1)

Copy Markdown View Source

Behaviour for memory services.

Provides long-term memory across sessions — agents can store and search memories scoped by app + user. Mirrors Python ADK's BaseMemoryService.

Implementing a backend

defmodule MyVectorStore do
  @behaviour ADK.Memory.Store

  @impl true
  def search(app_name, user_id, query, opts) do
    # your vector search here
    {:ok, []}
  end

  # ... other callbacks
end

Summary

Callbacks

Add memory entries.

Add all events from a session to memory.

Delete all memories for a user scope.

Delete a specific memory entry by ID.

Search memories matching the query. Returns entries ranked by relevance.

Types

scope()

@type scope() :: {app_name :: String.t(), user_id :: String.t()}

Callbacks

add(app_name, user_id, entries)

@callback add(
  app_name :: String.t(),
  user_id :: String.t(),
  entries :: [ADK.Memory.Entry.t()]
) :: :ok | {:error, term()}

Add memory entries.

add_session(app_name, user_id, session_id, events)

(optional)
@callback add_session(
  app_name :: String.t(),
  user_id :: String.t(),
  session_id :: String.t(),
  events :: [ADK.Event.t()]
) :: :ok | {:error, term()}

Add all events from a session to memory.

clear(app_name, user_id)

(optional)
@callback clear(
  app_name :: String.t(),
  user_id :: String.t()
) :: :ok | {:error, term()}

Delete all memories for a user scope.

delete(app_name, user_id, entry_id)

@callback delete(
  app_name :: String.t(),
  user_id :: String.t(),
  entry_id :: String.t()
) :: :ok | {:error, term()}

Delete a specific memory entry by ID.

search(app_name, user_id, query, opts)

@callback search(
  app_name :: String.t(),
  user_id :: String.t(),
  query :: String.t(),
  opts :: keyword()
) :: {:ok, [ADK.Memory.Entry.t()]} | {:error, term()}

Search memories matching the query. Returns entries ranked by relevance.