> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/build/agent/cross-conversation-search.md).

# 跨對話檢索

讓 Agent 在同一位聯絡人的近期對話中搜尋相關內容

跨對話檢索讓 Agent 在回覆時，搜尋同一位聯絡人在同一個收件匣中的近期對話。適合需要延續服務紀錄，但使用者可能經常開啟新對話的情境。

{% hint style="info" %}
此功能預設關閉。開啟後只會放寬 Agent 的搜尋範圍，不會把不同聯絡人或不同收件匣的內容混在一起。
{% endhint %}

## 開啟跨對話檢索 <a href="#enable-cross-conversation-search" id="enable-cross-conversation-search"></a>

{% stepper %}
{% step %}
在左側選單點選「<mark style="color:blue;">AI 助理</mark>」。
{% endstep %}

{% step %}
選擇要設定的 Agent，進入「<mark style="color:blue;">設定</mark>」。
{% endstep %}

{% step %}
開啟「<mark style="color:blue;">進階設定</mark>」。
{% endstep %}

{% step %}
在對話記憶設定中開啟「<mark style="color:blue;">跨對話檢索</mark>」。
{% endstep %}

{% step %}
在「<mark style="color:blue;">可回溯天數</mark>」輸入 1 至 365 天。預設為 90 天。

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-0ab9e819423da3a4cd8304212b77e9296e4d6975%2Fcross-conversation-search-settings.png?alt=media" alt="對話記憶設定區塊中，跨對話檢索開關已開啟，下方可回溯天數欄位為 90"><figcaption><p>開啟跨對話檢索後，下方出現可回溯天數欄位，預設為 90 天</p></figcaption></figure>
{% endstep %}

{% step %}
點選「<mark style="color:blue;">儲存</mark>」。
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
回溯天數越長，可搜尋的歷史範圍越大。請依服務需求設定，並遵循組織的資料使用與隱私規範。
{% endhint %}

## 對話記憶設定裡的其他選項 <a href="#other-memory-settings" id="other-memory-settings"></a>

「<mark style="color:blue;">跨對話檢索</mark>」 所在的 <mark style="color:blue;">對話記憶設定</mark> 區塊還有下列選項：

| 選項                                            | 畫面說明                                           | 什麼時候調整                                                                                         |
| --------------------------------------------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| <mark style="color:blue;">向量記憶</mark>         | 啟用時，歸檔的對話訊息會進行向量化和事實提取，用於語義檢索。關閉時，僅使用當前對話歷史視窗。 | 對話很長、需要讓 Agent 找回較早訊息時開啟；只處理短對話、想省向量化成本時關閉                                                     |
| <mark style="color:blue;">Embedding 模型</mark> | 用於將對話內容轉換為向量，影響對話記憶檢索與上下文理解的準確度                | 這裡選的是「對話記憶」用的模型，與知識庫設定頁的 Embedding 模型是兩回事；標示 <mark style="color:blue;">預設</mark> 的由平台設定，一般不需更換 |
| <mark style="color:blue;">Reranker 模型</mark>  | 用於重新排序檢索結果，提升檢索精準度                             | 同上，影響的是對話記憶的重排序                                                                                |
| <mark style="color:blue;">工具結果截斷</mark>       | 自動截斷過大的工具回傳結果，避免記憶膨脹                           | 見 [進階設定裡的其他開關](/build/agent/custom-max-tokens.md#other-advanced-switches)                      |

長期保存事實與偏好的 <mark style="color:blue;">持久記憶</mark> 是另一個區塊，見 [持久記憶](/build/agent/persistent-memory.md)。

## 使用情境 <a href="#use-case" id="use-case"></a>

小麥科技的客服助理負責追蹤售後案件。顧客在上週的對話中提供訂單狀況，今天另開新對話詢問進度。管理者為客服助理開啟跨對話檢索，並把可回溯天數設為 30 天；儲存後，Agent 便可透過對話歷史工具找到同一位顧客近期對話中的相關內容，再依找到的紀錄回覆。

## 功能範圍 <a href="#scope" id="scope"></a>

跨對話檢索的範圍包括：

* 同一位聯絡人
* 同一個收件匣
* 未刪除的一般聊天對話
* 最後一則訊息落在設定天數內的對話

符合回溯範圍的對話會納入整段訊息，而不只納入回溯期間內的訊息。系統最多選取最近有活動的 200 段對話；目前這一段對話則不受回溯天數限制，永遠會納入搜尋範圍。

關閉功能後，Agent 只會搜尋目前這一段對話。跨對話檢索與「向量記憶」是兩個獨立設定，可以分別開啟或關閉。


---

# 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.maiagent.ai/build/agent/cross-conversation-search.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.
