> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/quick-start.md).

# 快速开始

为角色启用记忆，并使用 Convai 仪表板和 Unity Editor 验证跨会话回忆。

## 你的首次跨会话记忆

长期记忆要正常工作，需要满足两个条件：在 Convai 控制面板中为角色启用记忆，并且 SDK 在每次会话中发送稳定的用户标识符。第二项由 `DeviceEndUserIdProvider`自动处理。本指南介绍从零开始，让角色记住你的最简步骤。

{% hint style="info" %}
**前提条件**

* 你的 Convai API 密钥已在 **工具 → Convai → 配置**.
* 一个场景中已配置并正常运行 `ConvaiCharacter` 组件（角色应能响应语音）。
  {% endhint %}

## 步骤

{% stepper %}
{% step %}
**为角色启用记忆**

打开 [Convai 控制面板](https://convai.com) 并选择你的角色。前往 **记忆 → 记忆设置** 并启用 **长期记忆** 开关。

这是一项需主动选择启用的设置——记忆 **默认处于关闭状态**。启用此选项之前，角色不会积累或使用记忆。如需了解控制面板界面的完整操作说明，请参阅 [记忆设置文档](https://docs.convai.com/api-docs/convai-playground/character-customization/memory#memory-settings).

{% hint style="warning" %}
启用记忆会影响该角色在所有部署中的所有会话，而不只是你的 Unity 项目。如果该角色与其他团队成员或项目共享，请先协调再启用。
{% endhint %}

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FOe3vEtLIt9dOZ91miZ9q%2Fimage.png?alt=media&amp;token=b12824ed-acdf-4e68-b341-faf642a75d9a" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**进入播放模式并开始对话**

按下 **播放** （Play），在 Unity 编辑器中开始与角色对话，并告诉它一些可以记住的信息——例如你的姓名、职位或偏好。比如：

> “我叫 Alex。我是夜班安全员。”

让角色回复，然后 **停止播放模式**.
{% endstep %}

{% step %}
**重新进入 Play Mode 并验证记忆召回**

再次按下 **播放** （Play），并与同一个角色开始新的对话。让它回忆自己知道的信息：

> “你还记得我是谁吗？”

如果长期记忆正常工作，角色会提及上一会话中的信息，无需你再次告知。
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**预期结果：** 角色会主动提及你的姓名或职位。它不会逐字复述——AI 会将存储的记忆自然地融入回复中。
{% endhint %}

## 刚刚发生了什么

在这段无缝体验背后，有四件事自动发生：

1. **身份：** SDK 调用了 `DeviceEndUserIdProvider`，它从 `PlayerPrefs` 中读取了一个稳定的 GUID（键： `"convai.end_user_id"`）。在编辑器中，这台机器的每次播放模式会话都会使用同一个 GUID。
2. **连接：** 会话开始时，该 GUID 会作为 `end_user_id` 发送到 Convai 服务器。
3. **记忆召回：** 服务器将 GUID 解析为内部说话人记录，加载了 `speaker_id:character_id` 组合对应的记忆，并在首次响应前将其注入 AI 的上下文中。
4. **记忆存储：** 首次会话结束时，后端从对话中提取事实（你的姓名、你的角色），并将其存储为分区中的 `MemoryRecord` 条目。

{% hint style="warning" %}
**编辑器身份说明：** 在 Unity 编辑器中，同一台机器上的所有播放模式会话共享同一个 `end_user_id`。这是为了确保测试稳定而有意设计的。它并不反映玩家构建版本的行为；在玩家构建版本中，每台物理设备都有自己的标识符。详情请参阅 [最终用户身份](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/end-user-identity.md) 了解全貌。
{% endhint %}

## 后续步骤

* 若要了解用户标识符的工作方式，以及如何将其替换为自己的标识符： [最终用户身份](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/end-user-identity.md)
* 若要通过编程方式而非通过控制面板启用或禁用记忆： [在角色上启用记忆](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/enabling-memory-on-characters.md)
* 若要通过代码添加、列出或删除记忆记录： [记忆管理 API](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/memory-management-api.md)
* 若要查看和管理已积累记忆的用户： [最终用户管理](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/end-user-management.md)

## 总结

在控制面板中启用记忆并使用默认身份提供程序后，你的角色就会完全自动地在每次会话中积累并召回特定于用户的事实。如果项目需要用户账户、自定义身份或直接控制记忆内容，本节其余部分将介绍相应工具。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/quick-start.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
