memory
Lakebase-backed Mastra memory wiring.
Provides a MemoryBuilder that mints one Memory per agent
with two independent knobs:
- Storage (threads / messages via
PostgresStore): defaults to per-agent namespacing via agentStorageSchemaName so conversation history stays isolated between agents in the same database.PostgresStoreauto-creates the schema withCREATE SCHEMA IF NOT EXISTSon init. A failed migration (common on Lakebase when the connecting role is not the table owner) is logged and skipped via withSoftStorageInit so existing tables keep serving instead of retrying DDL on every request. - Memory (semantic recall via
PgVector): defaults to a single shared instance across every agent. Cross-agent recall on one index is almost always what users want; opt into per-agent recall by passing a MastraMemoryConfigOverride on the agent.
Additionally, MemoryBuilder.instanceStorage returns a
Mastra-instance-level PostgresStore (schema mastra_instance)
used for workflow snapshots - the persistence layer
agent.resumeStream() reads from when waking a suspended
requireApproval tool call. Per-agent stores are not enough for
this: workflow runs are scoped to the Mastra instance, not an
individual agent’s Memory.
Plugin-level config.storage / config.memory act as the baseline
(auto-defaulted to true in plugin.ts when the lakebase plugin
is registered); per-agent settings cascade on top of that.