Skip to main content

Agent.getMemory()

The .getMemory() method retrieves the memory system associated with an agent. This method is used to access the agent's memory capabilities for storing and retrieving information across conversations.

Usage example
Direct link to Usage example

await agent.getMemory();

Parameters
Direct link to Parameters

options?:

{ requestContext?: RequestContext }
= {}
Optional configuration object containing request context.

Returns
Direct link to Returns

memory:

Promise<MastraMemory | undefined>
A promise that resolves to the memory system configured for the agent, or undefined if no memory system is configured.

Extended usage example
Direct link to Extended usage example

await agent.getMemory({
requestContext: new RequestContext(),
});

Options parameters
Direct link to Options parameters

requestContext?:

RequestContext
= new RequestContext()
Request Context for dependency injection and contextual information.

On this page