LangEx.Checkpointer behaviour (LangEx v0.11.3)

Copy Markdown View Source

Behaviour for checkpoint persistence backends.

Implement this behaviour to add custom storage (e.g., S3, DynamoDB). Built-in implementations: LangEx.Checkpointer.Redis, LangEx.Checkpointer.Postgres.

Summary

Callbacks

Deletes every checkpoint belonging to the thread in the config.

Lists checkpoints for a thread, most recent first.

Loads the latest checkpoint for the given thread.

Persists a checkpoint.

Types

config()

@type config() :: keyword()

Callbacks

delete_thread(config)

@callback delete_thread(config()) :: :ok | {:error, term()}

Deletes every checkpoint belonging to the thread in the config.

list(config, keyword)

@callback list(
  config(),
  keyword()
) :: [LangEx.Checkpoint.t()] | {:error, term()}

Lists checkpoints for a thread, most recent first.

load(config)

@callback load(config()) :: {:ok, LangEx.Checkpoint.t()} | :none | {:error, term()}

Loads the latest checkpoint for the given thread.

When the config includes a :checkpoint_id, that specific checkpoint is loaded instead (time travel / forking).

save(config, t)

@callback save(config(), LangEx.Checkpoint.t()) :: :ok | {:error, term()}

Persists a checkpoint.