> 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/add-system-prompt.md).

# 為 Agent 加入角色指令

把設計好的角色指令（System Prompt）填入 Agent 設定：進入 Agent 編輯頁、貼上角色指令並儲存的操作步驟。

角色指令設計完成後，您可以在 MaiAgent 的 Agent 設定中加入角色指令：

## 加入角色指令 <a href="#add-system-prompt" id="add-system-prompt"></a>

### 1. 進入 Agent 設定頁面 <a href="#step-1-navigate-to-ai-agent-settings" id="step-1-navigate-to-ai-agent-settings"></a>

於左側選單點選 <mark style="color:blue;">AI 功能</mark> > <mark style="color:blue;">AI 助理</mark>，在列表中找到您要設定的 Agent，點按該列 <mark style="color:blue;">操作</mark> 欄的 <mark style="color:blue;">編輯</mark> 圖示。

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-4d2b79176a41568cb0cd9e0dc9e201b5671a6a6a%2Fai-agent-list-edit-button.png?alt=media" alt="Agent 列表，操作欄的編輯圖示已標示"><figcaption><p>點按操作欄的編輯圖示進入 Agent 設定</p></figcaption></figure>

### 2. 切換至回答模式設定頁面 <a href="#step-2-switch-to-answer-mode-settings" id="step-2-switch-to-answer-mode-settings"></a>

在 <mark style="color:blue;">設定</mark> 分頁左側的設定選單中，點選 <mark style="color:blue;">回答模式設定</mark>。

將 <mark style="color:blue;">回答模式</mark> 設置為 <mark style="color:blue;">RAG 問答</mark>、<mark style="color:blue;">Agent 模式</mark>，或展開 <mark style="color:blue;">其他模式</mark> 選擇 <mark style="color:blue;">混合</mark>：

{% hint style="warning" %}
「模板」模式（位於 <mark style="color:blue;">其他模式</mark> 內）無法設置角色指令
{% endhint %}

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-b814b654848f855a4cfe488c9517e7388c11cb3a%2Fai-agent-reply-mode-settings.png?alt=media" alt="設定分頁的回答模式設定，顯示 RAG 問答、Agent 模式與其他模式選項"><figcaption><p>於回答模式設定中選擇回答模式</p></figcaption></figure>

### 3. 在角色指令區段加入文字 <a href="#step-3-enter-text-in-system-prompt-section" id="step-3-enter-text-in-system-prompt-section"></a>

在同一頁下方的 <mark style="color:blue;">角色指令</mark> 區段輸入角色指令內容，完成後點按右下角的 <mark style="color:blue;">儲存</mark>。

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-f56ca83283c5e1689fde5ff2f3808aa9ac70d906%2Fai-agent-instructions-field.png?alt=media" alt="角色指令區段，含使用提示、快速插入提示詞與輸入框"><figcaption><p>在角色指令區段輸入內容</p></figcaption></figure>

如此一來，Agent 就會根據您所定義的角色指令行動，成為您專屬的 Agent。

## 角色指令的編輯紀錄 <a href="#instruction-edit-history" id="instruction-edit-history"></a>

角色指令每次儲存都會留下一個版本。點 <mark style="color:blue;">角色指令</mark> 區段的 「<mark style="color:blue;">編輯紀錄</mark>」，會以時間軸列出歷次儲存的時間與完整內容（最新的在最上面，往下捲動會載入更早的版本）。將滑鼠移到某個版本上會出現兩個按鈕：

| 按鈕                                      | 作用                                                                                              |
| --------------------------------------- | ----------------------------------------------------------------------------------------------- |
| <mark style="color:blue;">套用</mark>     | 把該版本的內容填回角色指令欄位並關閉視窗。要生效仍需按右下角的 <mark style="color:blue;">儲存</mark>，所以可以先比對內容、不滿意再改回來           |
| <mark style="color:blue;">檢視訊息紀錄</mark> | 開啟「使用該版本角色指令期間」的對話紀錄清單，每筆可點 「<mark style="color:blue;">查看回覆品質控管詳情</mark>」 看完整問答；用來對照哪一版的回覆品質比較好 |

建議大幅修改前先開 「編輯紀錄」 確認目前版本；改壞了隨時可以套用舊版再儲存。


---

# 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/add-system-prompt.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.
