Raxol.Agent.ContextStore (Raxol Agent v2.6.0)

Copy Markdown View Source

ETS-backed persistent context that survives agent restarts.

Stores agent state snapshots keyed by agent_id. When an agent crashes and restarts, it can restore its context from here rather than starting from scratch.

Table: :raxol_agent_contexts, named_table, public, set, read_concurrency.

Summary

Functions

Deletes an agent's context.

Initializes the ETS table. Safe to call multiple times.

Lists all agent ids that have stored contexts.

Loads the most recent context snapshot for an agent.

Saves a context snapshot for an agent.

Updates an agent's context by applying a transformation function.

Functions

delete(agent_id)

@spec delete(atom()) :: :ok

Deletes an agent's context.

init()

@spec init() :: :ok

Initializes the ETS table. Safe to call multiple times.

list()

@spec list() :: [atom()]

Lists all agent ids that have stored contexts.

load(agent_id)

@spec load(atom()) :: {:ok, map()} | {:error, :not_found}

Loads the most recent context snapshot for an agent.

save(agent_id, context)

@spec save(atom(), map()) :: :ok

Saves a context snapshot for an agent.

update(agent_id, fun)

@spec update(atom(), (map() -> map())) :: {:ok, map()} | {:error, :not_found}

Updates an agent's context by applying a transformation function.