> 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 蓝图节点触发时，请使用此页面 **失败时**。先进行首要检查，然后根据你遇到的情况查看相应的症状条目。

### 首要检查

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

### 决策流程

```mermaid
graph TD
    startNode["角色不记得"] --> ltmStatus["已启用 LTM？"]
    ltmStatus -->|"否"| enableLtm["启用 LTM 并重新测试"]
    ltmStatus -->|"是"| identityStable["各会话使用相同的 EndUserID？"]
    identityStable -->|"否"| fixIdentity["持久化 SpeakerID 或账户 ID"]
    identityStable -->|"是"| sessionWorked["会话是否成功连接？"]
    sessionWorked -->|"否"| fixConnection["修复 API 密钥或网络问题"]
    sessionWorked -->|"是"| retryConversation["进行一次有实质内容的对话，然后重新测试"]
```

### 角色始终记不住之前的会话

**症状：** 即使玩家在之前的会话中分享过信息，角色每次启动时仍像是全新开始。

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

**修复方法：**

1. 调用 **Convai Get LTM Status** 并传入角色 ID。
2. 如果 **Status** 为 `false`，则调用 **Convai Set LTM Status** 并将 **B Enable** 设为 `true`.
3. 在紧接着之前打印 `UConvaiChatbotComponent.EndUserID` 之前 `StartSession`.

**验证：** 运行两个具有相同 `EndUserID` 的「在编辑器中运行」会话，并在每次调用聊天机器人组件上的 `StartSession`.

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

**症状：** 角色提到了另一位玩家的相关信息。

**原因：** 多个玩家共用了相同的 `EndUserID`。在共用设备上使用设备回退时，常会出现这种情况。

**修复方法：** 为每位玩家创建或分配唯一身份标识。若通过蓝图管理身份标识，请为每位玩家档案调用一次 **Convai Create Speaker ID** ，并保存其返回的 `SpeakerID`。请参阅 [终端用户身份](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).

**验证：** 在每个档案调用 `EndUserID` 之前，打印当前生效的 `StartSession`。每位玩家的值都应不同。

### Convai Create Speaker ID 失败

**症状：** **Convai Create Speaker ID** 触发了 **On Failure**.

**原因：** 输入的 **Speaker Name** 为空，或 HTTP 请求失败。

**修复方法：** 将 **Speaker Name** 设为非空字符串。如果该值为空，插件会记录 `Speaker name is empty` 并触发 **On Failure**.

如果名称有效，请在输出日志中检查基础 API 代理返回的通用 HTTP 失败消息：

```
HTTP request failed with code %d, and with response:%s
```

**验证：** 修复输入或连接问题后，调用 **Convai List Speaker IDs** 并确认返回的数组中包含新的 `SpeakerID` 。

### 说话人 ID 列表为空

**症状：** **Convai 列出说话人 ID** 成功，但未返回任何记录。

**原因：** 配置的 API 密钥没有说话人 ID 记录，或者测试记录已被删除。

**修复方法：** 使用以下功能创建新的说话人 ID： **Convai 创建说话人 ID**，然后再次调用 **Convai 列出说话人 ID** 。

**验证：**  **成功时** 数组中包含一个 `FConvaiSpeakerInfo` ，其 `SpeakerID`.

### 删除说话人 ID 后，本地状态未清除

**症状：** 重新启动后，已删除的身份仍被分配。

**原因：** 项目从 Convai 删除了说话人 ID，但未清除本地保存的 `SpeakerID`.

**修复方法：** 在 **Convai 删除说话人 ID** 成功后，清除本地保存的 `SpeakerID`.

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

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

当前源代码中包含以下 LTM 专属日志消息：

| 日志消息                                                     | 出现位置                 | 含义                             |
| -------------------------------------------------------- | -------------------- | ------------------------------ |
| `Speaker name is empty`                                  | **Convai 创建说话者 ID**  | **说话人名称** 为空。                  |
| `Parse Json failed`                                      | **Convai 创建说话者 ID**  | 无法解析创建响应。                      |
| `Parse speaker id failed`                                | **Convai 列出说话者 ID**  | 无法解析列表响应。                      |
| `GetLTMStatus failed`                                    | **Convai 获取 LTM 状态** | 角色详情响应中未包含预期的 LTM 状态数据。        |
| `End User ID not provided, using Device ID: %s`          | 连接参数构建               | 聊天机器人 `EndUserID` 为空；已使用设备回退值。 |
| `Using End User ID: %s`                                  | 连接参数构建               | 聊天机器人 `EndUserID` 已在连接时发送。     |
| `HTTP request failed with code %d, and with response:%s` | 共享 API 代理            | HTTP 请求返回了非 2xx 响应。            |

### Unreal LTM 未提供的功能

Unreal 插件提供 Speaker ID 管理功能，以及角色 LTM 的启用状态。它不提供用于列出、添加、检索或删除单条记忆记录的 Blueprint 节点。

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

### 后续步骤

{% content-ref url="/pages/02906b279025410eed0c91dd64f1012b0304b626" %}
[为角色配置记忆](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)
{% endcontent-ref %}

{% content-ref url="/pages/49e163546e7059153712733c44aa93aee597bbbe" %}
[终端用户身份](https://docs.convai.com/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" %}
[长期记忆快速开始](https://docs.convai.com/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 管理](https://docs.convai.com/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 参考](https://docs.convai.com/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.
