production beginner

Persistence Storage Agent

Focused round-trip example for Persist.hibernate/2 and Persist.thaw/3 using ETS-backed checkpoints.

persistence storage operations ops-governance l1

Related guides and notebooks

lib/agent_jido/demos/persistence_storage/persistence_storage_agent.ex 25 lines
defmodule AgentJido.Demos.PersistenceStorageAgent do
  @moduledoc """
  Demo agent for persistence round-trips with `Jido.Persist`.
  """

  alias AgentJido.Demos.PersistenceStorage.{AddNoteAction, IncrementAction}

  use Jido.Agent,
    name: "persistence_storage_agent",
    description: "Demonstrates hibernate/thaw with ETS storage",
    schema: [
      counter: [type: :integer, default: 0],
      status: [type: :atom, default: :idle],
      notes: [type: {:list, :string}, default: []]
    ],
    signal_routes: [
      {"counter.increment", IncrementAction},
      {"notes.add", AddNoteAction}
    ]

  @doc false
  @spec plugin_specs() :: nonempty_list(Jido.Plugin.Spec.t())
  def plugin_specs, do: super()
end