docs/src/content/en/reference/agents/getMemory.mdx
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.
await agent.getMemory()
<PropertiesTable content={[ { name: 'options', type: '{ requestContext?: RequestContext }', isOptional: true, defaultValue: '{}', description: 'Optional configuration object containing request context.', properties: [ { type: '{ requestContext?: RequestContext }', parameters: [ { name: 'requestContext', type: 'RequestContext', isOptional: true, defaultValue: 'new RequestContext()', description: 'Request Context for dependency injection and contextual information.', }, ], }, ], }, ]} />
<PropertiesTable content={[ { name: 'memory', type: 'Promise<MastraMemory | undefined>', description: 'A promise that resolves to the memory system configured for the agent, or undefined if no memory system is configured.', }, ]} />
await agent.getMemory({
requestContext: new RequestContext(),
})