跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

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
Usage example的直接链接

await agent.getMemory()

Parameters
Parameters的直接链接

options?:

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

requestContext?:

RequestContext
Request Context for dependency injection and contextual information.

Returns
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
Extended usage example的直接链接

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