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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MemoryBuilder(
config,servicePrincipalPool):MemoryBuilder
Parameters
Section titled “Parameters”config
Section titled “config”servicePrincipalPool
Section titled “servicePrincipalPool”Pool
Returns
Section titled “Returns”MemoryBuilder
Methods
Section titled “Methods”forAgent()
Section titled “forAgent()”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.
Parameters
Section titled “Parameters”agentId
Section titled “agentId”string
Returns
Section titled “Returns”Memory | undefined
instanceStorage()
Section titled “instanceStorage()”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.
Returns
Section titled “Returns”PostgresStore | undefined