translation/translated/documents/course/03-agent-memory/07-understanding-memory-thr...

15 lines
942 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 管理对话历史
在这一步中,我们将学习如何配置对话历史并理解 Mastra 中的内存线程。对话历史允许你的智能体记住最近的交互,这对于在正在进行的对话中保持上下文至关重要。
## 理解内存线程
Mastra 将内存组织成线程,这些是识别特定对话历史的记录。每个线程使用两个重要的标识符:
1. **`threadId`**:特定的对话 ID例如`support_123`
2. **`resourceId`**:拥有每个线程的用户或实体 ID例如`user_alice`
这些标识符使内存在 playground 之外正常工作。它们帮助 Mastra 区分不同的对话和用户,确保正确的内存与正确的对话相关联。
没有这些标识符当用户发送消息时你的智能体将无法知道检索哪个对话历史。playground 自动处理这些标识符,但在自己的应用程序中使用内存时,你需要自己管理它们。