Skip to main content

Agent.getMemory()

.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.

使用示例
Direct link to 使用示例

🌐 Usage example

await agent.getMemory();

参数
Direct link to 参数

🌐 Parameters

options?:

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

返回
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.

扩展使用示例
Direct link to 扩展使用示例

🌐 Extended usage example

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

选项参数
Direct link to 选项参数

🌐 Options parameters

requestContext?:

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

🌐 Related