@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
32 lines (20 loc) • 970 B
Markdown
# 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
```typescript
await agent.getMemory()
```
## Parameters
**options** (`{ requestContext?: RequestContext }`): Optional configuration object containing request context. (Default: `{}`)
**options.requestContext** (`RequestContext`): Request Context for dependency injection and contextual information.
## 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
```typescript
await agent.getMemory({
requestContext: new RequestContext(),
})
```
## Related
- [Memory](https://mastra.ai/docs/memory/overview)
- [Request Context](https://mastra.ai/docs/server/request-context)