ExAgent.Memory.Postgres (ExAgent v2.3.0)

View Source

A durable ExAgent.Memory backend on PostgreSQL, through the host's Ecto.Repo (add ecto_sql and postgrex to your app, as for ExAgent.Store.Postgres).

# once, from a migration or at boot:
:ok = ExAgent.Memory.Postgres.migrate(MyApp.Repo)

ExAgent.Memory.tool({ExAgent.Memory.Postgres, MyApp.Repo}, scope: "user:42")

Each scope is one row: scope (primary key), version, data (the files as JSON text) and updated_at. Versions come from a sequence, so they are never reused, and every write is a single conditional statement. The table is exagent_memory by default; choose another with {ExAgent.Memory.Postgres, {MyApp.Repo, table: "agent_memory"}} (at most 48 characters, letters, digits and underscores) and create it with migrate(MyApp.Repo, "agent_memory").

Summary

Functions

Create the memory table and its version sequence (idempotent).

Functions

migrate(repo, table \\ "exagent_memory")

@spec migrate(module(), String.t()) :: :ok | {:error, term()}

Create the memory table and its version sequence (idempotent).