Skip to content

Class: MemoryBuilder

Builds one Memory per agent against a shared service-principal Lakebase pool. Per-instance state keeps the shared PgVector alive across calls so registering N agents stays cheap.

new MemoryBuilder(config, servicePrincipalPool): MemoryBuilder

MastraPluginConfig

Pool

MemoryBuilder

forAgent(agentId, def): Memory | undefined

Build a Memory for agentId after the plugin/agent cascade. Returns undefined when the agent has neither storage nor a vector store enabled - Mastra accepts a missing memory field and treats the agent as stateless.

string

MastraAgentDefinition

Memory | undefined


instanceStorage(): PostgresStore | undefined

Build the Mastra-instance-level storage used for workflow snapshots. Returns undefined when plugin-level storage is disabled, in which case agent.resumeStream() (and therefore the requireApproval flow) will not be available.

The store lives in a dedicated mastra_instance schema so it never collides with per-agent agentStorageSchemaName namespaces. Workflow snapshots are not per-agent state; they belong to the Mastra instance that owns the workflow execution.

PostgresStore | undefined