> 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/hook/execution-logs.md).

# Hook 執行紀錄

Hook 每一次的攔截、改寫、放行都會留下紀錄。對受監管的產業（金融、醫療、政府）來說，**「可追溯」本身就是合規要求**——出了問題要查得到「哪一則訊息、被哪條規則、做了什麼處置、什麼時間」。

<figure><img src="/files/h2BGbkb23U0WxSqtyxs1" alt="Hook 執行紀錄與客製化能力"><figcaption><p>執行紀錄（Audit Log）完整記錄每次處置：命中規則、處置動作、處理結果與時間戳，支援關鍵字搜尋、依助理篩選與匯出報表</p></figcaption></figure>

## <mark style="color:blue;">一、查看執行紀錄</mark> <a href="#view-logs" id="view-logs"></a>

從左側選單進入 <mark style="color:blue;">AgentOps</mark> →〈<mark style="color:blue;">Hook 執行紀錄</mark>〉。你可以看到每一筆執行的：

* **時間**——何時發生
* **助理**——哪個 AI 助理觸發的
* **命中規則**——是哪一個 Hook 處理的
* **處置**——做了什麼（遮罩改寫／攔截封鎖／放行）
* **狀態**——處理結果

你可以用**日期區間、助理、關鍵字**篩選，也能**匯出報表**做進一步稽核分析。頁面上方也會顯示**總執行次數、命中次數、命中率**的統計。

<figure><img src="/files/ljcAwQSOZDUxx0N4wl12" alt="Hook 執行紀錄列表"><figcaption><p>執行紀錄列表：每筆顯示 AI 助理、Hook 名稱、觸發點、動作與結果。可看到個資遮罩把手機改成 [REDACTED_PHONE]、敏感詞與提示注入被封鎖等實際處置</p></figcaption></figure>

### 查看單筆詳情 <a href="#log-detail" id="log-detail"></a>

點開任一筆紀錄，會顯示這次處置的完整脈絡：**基本資訊（Hook 名稱、類型、觸發點、動作、結果）、關聯資訊、訊息內容**，讓你清楚知道系統做了什麼。

<figure><img src="/files/KNzvKs7scEuxB5jHv2ht" alt="Hook 執行紀錄單筆詳情"><figcaption><p>單筆詳情：以個資遮罩為例，可看到動作為 modify、訊息內容已遮罩為 [REDACTED_PHONE]</p></figcaption></figure>

## <mark style="color:blue;">二、控制是否記錄原始訊息</mark> <a href="#log-privacy-toggle" id="log-privacy-toggle"></a>

執行紀錄預設**只記錄「處置結果」，不保留原始的敏感內容**——這是為了避免個資或敏感訊息又被留存在紀錄裡。

若你在除錯階段需要看到「原始內容長什麼樣」，可以在 Hook 的設定頁把 <mark style="color:blue;">記錄遮罩前原始值</mark> 開關由 `off` 改成 `on`。開啟後，紀錄會額外保留遮罩前／攔截前的原始內容，方便追查。

<figure><img src="/files/tFMHCoW6GRV0bwkelPSE" alt="記錄遮罩前原始值開關"><figcaption><p>在 Hook 設定頁的「記錄遮罩前原始值」欄位控制：預設 off（只記型別與次數，不留原始個資），需要除錯時才改成 on</p></figcaption></figure>

{% hint style="warning" %}
**隱私權衡：** 開啟「記錄原始值」等於把原始的個資／訊息內容留存在執行紀錄中。**基於資安考量，建議平時維持關閉**，只在需要排查問題時暫時開啟。
{% endhint %}

## <mark style="color:blue;">三、從對話中查看 Hook 執行詳情</mark> <a href="#from-conversation" id="from-conversation"></a>

除了集中式的執行紀錄，你也可以**從實際對話回頭追查**：進入 <mark style="color:blue;">客服對話</mark> →〈<mark style="color:blue;">所有對話</mark>〉，開啟任一則對話，就能看到該對話中哪些訊息被 Hook 處理過（遮罩或攔截），對應到當下的處置。

這讓你在檢視客戶對話時，能直接理解「為什麼這則訊息被遮罩／被擋下」，不必另外比對紀錄。

## <mark style="color:blue;">四、相關頁面</mark> <a href="#related" id="related"></a>

* [Hook 訊息攔截總覽](/hook/hook.md)——Hook 是什麼、五種標準範本
* [新增與設定 Hook](/hook/setup.md)——如何建立、設定參數、關聯 AI 助理


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.maiagent.ai/hook/execution-logs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
