> 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/convai-unreal-engine-plugin/features/long-term-memory/configure-memory-for-a-character.md).

# 为角色配置记忆

为 Unreal 角色启用长期记忆，验证仪表板设置，并在需要时重置本地对话链接。

配置一个 Convai 角色，使其能够记住回归玩家。启用角色级 LTM 设置，确认其已生效，并在需要新的对话线程时重置本地会话链接。

### 前置条件

* Convai Unreal Engine 插件已安装，且 API 密钥已配置。
* 该角色 Actor 有一个 `UConvaiChatbotComponent` 中注册，并且具有有效的 `CharacterID`.
* 玩家身份已配置。请参见 [终端用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).

### 为该角色启用 LTM

在 Convai 仪表板中，新角色默认禁用 LTM。对于每个应建立持久记忆的角色，请启用它。

{% stepper %}
{% step %}

#### 检查当前状态

添加 **Convai 获取 LTM 状态** 来自 `Convai|LTM` 类别。

设置 **角色 ID** 到 Convai 仪表板中的角色 ID。该 **成功时** 委托返回 **状态** 作为一个 `bool`.
{% endstep %}

{% step %}

#### 如有需要则启用记忆

如果 **状态** 是 `false`的情况下推送一个值，请调用 **Convai Set LTM Status** 使用相同的 **角色 ID** 和 **B 启用** 设置为 `true`.

绑定 **成功时** 到可见的确认项，例如 **打印字符串** 在测试时。
{% endstep %}

{% step %}

#### 验证该设置

调用 **Convai 获取 LTM 状态** 再次。仅当 **状态** 返回 `true`.
{% endstep %}
{% endstepper %}

### 重置会话链接

使用 `ResetConversation()` 当玩家开始新的流程、切换配置文件，或需要一个全新的对话会话而不删除长期记忆时。

{% tabs %}
{% tab title="蓝图" %}
调用 **重置对话** 在 **Convai 聊天机器人** 组件。
{% endtab %}

{% tab title="C++" %}

```cpp
ChatbotComponent->ResetConversation();
```

{% endtab %}
{% endtabs %}

`ResetConversation()` 将本地 `SessionID` 属性设置为 `"-1"`。它不会删除玩家的 Speaker ID 或 Convai 中的单独记忆记录。相同的 `EndUserID` 仍会继续为该玩家限定长期记忆范围。

{% hint style="info" %}
`UConvaiChatbotComponent.SessionID` 默认为 `"-1"` 并会被以下操作清除 `ResetConversation()`。WebRTC 连接不会发送此属性。请将其用于本地重置跟踪或 HTTP Bot Query 流程。
{% endhint %}

### 验证配置

在……之前 `StartSession`，请确认：

* **Convai 获取 LTM 状态** 返回 `true`.
* `UConvaiChatbotComponent.EndUserID` 已设置为一个非空、稳定的值。
* `SessionID` 是 `"-1"` 在 `ResetConversation()`，或者在使用相同身份继续时保持不变。

有关身份分配步骤，请参见 [终端用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).

### 下一步

{% content-ref url="/pages/fe714c4b4449c797215a2b49fe82fef8879c959a" %}
[长期记忆使用示例](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/long-term-memory-usage-examples.md)
{% endcontent-ref %}

{% content-ref url="/pages/d52ddbffaafeb3f6c5f97016d40633bc7ea09f16" %}
[LTM Blueprint 参考](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/ltm-blueprint-reference.md)
{% endcontent-ref %}

{% content-ref url="/pages/1207dad324341231dae358387602c84854559b9c" %}
[排查长期记忆问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/troubleshoot-long-term-memory.md)
{% endcontent-ref %}


---

# 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/convai-unreal-engine-plugin/features/long-term-memory/configure-memory-for-a-character.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.
