> 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/troubleshoot-long-term-memory.md).

# 排查长期记忆问题

诊断已禁用记忆、不稳定的玩家身份、说话者身份失败以及 Unreal 角色在共享设备上的回忆问题。

当 Convai 角色不记得回访玩家、记错玩家，或 LTM Blueprint 节点触发时，请使用此页面 **失败时**。先从第一线检查开始，然后使用与您看到的症状相匹配的条目。

### 第一线检查

1. 确认已为该角色启用 LTM。在 Convai 仪表板中，新角色默认禁用记忆。在 Unreal 中，调用 **Convai 获取 LTM 状态** 并确认 **状态** 是 `true`.
2. 确认 `UConvaiChatbotComponent.EndUserID` 在每次之前都设置为非空且稳定的值 `StartSession`.
3. 确认聊天机器人和玩家组件使用相同的 `EndUserID` 之前 `StartSession`.
4. 确认已配置 API 密钥，并且其他 Convai 会话请求均已成功。

### 决策流程

```mermaid
graph TD
    startNode["角色不记得"] --> ltmStatus["已启用 LTM？"]
    ltmStatus -->|"No"| enableLtm["启用 LTM 并再次测试"]
    ltmStatus -->|"Yes"| identityStable["跨会话使用同一个 EndUserID？"]
    identityStable -->|"No"| fixIdentity["持久化 SpeakerID 或账户 ID"]
    identityStable -->|"Yes"| sessionWorked["会话已成功连接？"]
    sessionWorked -->|"No"| fixConnection["修复 API 密钥或网络问题"]
    sessionWorked -->|"Yes"| retryConversation["进行一次实质性对话并重新测试"]
```

### 角色从不记住之前的会话

**症状：** 即使玩家在早前的会话中分享过事实，角色每次都会从头开始。

**原因：** 该角色的 LTM 被禁用，或者 `EndUserID` 聊天机器人组件上的值在会话之间发生变化。

**修复：**

1. 调用 **Convai 获取 LTM 状态** 针对角色 ID。
2. 如果 **状态** 是 `false`，调用 **Convai 设置 LTM 状态** 并将 **B 启用** 设为 `true`.
3. Print `UConvaiChatbotComponent.EndUserID` 紧接在……之前 `StartSession`.

**验证：** 使用相同的 `EndUserID` 在聊天机器人组件上，在每次 `StartSession`.

### 角色记住了错误的玩家

**症状：** 该角色提到了另一位玩家的事实。

**原因：** 多个玩家正在共享相同的 `EndUserID`。当在共享机器上使用设备回退时，经常会发生这种情况。

**修复：** 为每位玩家创建或分配唯一身份。对于由 Blueprint 管理的身份，调用 **Convai 创建 Speaker ID** 对每个玩家配置文件调用一次，并保存返回的 `SpeakerID`。请参阅 [终端用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).

**验证：** 打印当前活动的 `EndUserID` 在每个配置文件之前 `StartSession`。每位玩家都应有一个不同的值。

### Convai 创建 Speaker ID 失败

**症状：** **Convai 创建 Speaker ID** 触发 **失败时**.

**原因：** 该 **Speaker 名称** 输入为空，或者 HTTP 请求失败。

**修复：** 设置 **Speaker 名称** 为非空字符串。如果该值为空，插件会记录 `Speaker 名称为空` 并触发 **失败时**.

如果名称有效，请在 Output Log 中查看来自基础 API 代理的共享 HTTP 失败消息：

```
HTTP 请求失败，代码为 %d，响应为：%s
```

**验证：** 修复输入或连接问题后，调用 **Convai 列出 Speaker ID** 并确认新的 `SpeakerID` 出现在返回的数组中。

### Speaker ID 列表为空

**症状：** **Convai 列出 Speaker ID** 成功，但没有返回记录。

**原因：** 为已配置的 API 密钥不存在任何 Speaker ID 记录，或者测试记录已被删除。

**修复：** 使用以下方式创建新的 Speaker ID **Convai 创建 Speaker ID**，然后调用 **Convai 列出 Speaker ID** 再次。

**验证：** 该 **成功时** 数组包含一个 `FConvaiSpeakerInfo` 带有非空 `SpeakerID`.

### 删除 Speaker ID 不会清除本地状态

**症状：** 在下一次启动时，已删除的身份仍然被分配。

**原因：** 项目已从 Convai 中删除了 Speaker ID，但没有清除本地保存的 `SpeakerID`.

**修复：** 在……之后 **Convai 删除 Speaker ID** 成功后，清除本地保存的 `SpeakerID`.

**验证：** 重新启动项目，并确认没有已删除的 `SpeakerID` 从保存数据中加载。

### 源代码验证的日志消息

当前源代码包含以下特定于 LTM 的日志消息：

| 日志消息                              | 出现位置                     | 含义                            |
| --------------------------------- | ------------------------ | ----------------------------- |
| `Speaker 名称为空`                    | **Convai 创建 Speaker ID** | **Speaker 名称** 为空。            |
| `解析 Json 失败`                      | **Convai 创建 Speaker ID** | 无法解析创建响应。                     |
| `解析 speaker id 失败`                | **Convai 列出 Speaker ID** | 无法解析列表响应。                     |
| `GetLTMStatus 失败`                 | **Convai 获取 LTM 状态**     | 角色详细信息响应中未包含预期的 LTM 状态数据。     |
| `未提供 End User ID，使用 Device ID：%s` | 连接参数构建                   | 聊天机器人 `EndUserID` 为空；已使用设备回退。 |
| `正在使用 End User ID：%s`             | 连接参数构建                   | 聊天机器人 `EndUserID` 已在连接时发送。    |
| `HTTP 请求失败，代码为 %d，响应为：%s`         | 共享 API 代理                | HTTP 请求返回了非 2xx 响应。           |

### Unreal LTM 未公开的内容

Unreal 插件公开了 Speaker ID 管理以及角色 LTM 启用状态。它不公开用于列出、添加、检索或删除单个记忆记录的 Blueprint 节点。

如需新的本地对话链接，请使用 `ResetConversation()`。对于身份删除，请使用 **Convai 删除 Speaker ID** 并附带确认步骤。

### 下一步

{% content-ref url="/pages/02906b279025410eed0c91dd64f1012b0304b626" %}
[为角色配置记忆](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/configure-memory-for-a-character.md)
{% endcontent-ref %}

{% content-ref url="/pages/49e163546e7059153712733c44aa93aee597bbbe" %}
[终端用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md)
{% endcontent-ref %}

{% content-ref url="/pages/ce3e385378b893a9b53a3930b98101901dc9d6d8" %}
[长期记忆快速开始](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/long-term-memory-quick-start.md)
{% endcontent-ref %}

{% content-ref url="/pages/490cd1c53fd291cb3dcb57f385b0eee013c3ae74" %}
[说话者 ID 管理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/speaker-id-management.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 %}


---

# 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/troubleshoot-long-term-memory.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.
