# Agent（AI 助理）

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-1a8d5c4f5730b01df936ff808693f50eb497759a%2Fagent-infographic.png?alt=media" alt="Agent 核心概念"><figcaption><p>Agent 核心運作流程：LLM 驅動 × 角色指令 × 記憶</p></figcaption></figure>

## 這是什麼？

Agent 是你在 MaiAgent 上建立的 AI 對話角色。每一個 Agent 都是一個獨立的對話機器人，有自己的身份、個性、知識和能力。

你可以把 Agent 想成一位新進員工——你需要告訴它：

* **你是誰**（角色指令 / System Prompt）
* **你知道什麼**（知識庫、資料庫）
* **你能做什麼**（工具、技能）

設定完成後，Agent 就能在各種對話平台上為使用者服務。

## 核心概念

### 語言模型（LLM）

Agent 的理解和回覆能力來自背後的大型語言模型（LLM）。你可以把 LLM 想成 Agent 的「腦力」——不同的模型在理解力、回覆品質、速度和成本上各有差異。

建立 Agent 時，你可以選擇適合場景的模型。MaiAgent 支援多種模型，包括 Claude、GPT 等，不需要自己管理模型，平台會幫你處理。

> **簡單判斷**：需要精準回覆、複雜推理 → 選較強的模型；高頻簡單問答、控制成本 → 選較快較輕的模型。

### 角色指令（System Prompt）

角色指令決定了 Agent 的行為方式。例如：

* 「你是一位親切的客服人員，用繁體中文回覆，語氣專業但不生硬。」
* 「你是一位財務分析助理，只回答與財務相關的問題，遇到不確定的數據請明確告知。」

好的角色指令會讓 Agent 的回覆品質大幅提升。

### 回覆模式

MaiAgent 提供兩種回覆模式：

* **Chat 模式**：適合一般問答，直接用知識庫內容回覆
* **Agent 模式**：適合需要多步驟推理的場景，Agent 會自行判斷要查什麼資料、用什麼工具

### 記憶

Agent 具備記憶能力：

* **對話記憶**：在同一輪對話中記得前面聊過的內容
* **長期記憶**：跨對話記住重要資訊，不用每次重新介紹

> **進階說明**：記憶功能讓 Agent 能在多輪對話中維持上下文連貫，並透過向量檢索回憶過去的對話內容。你可以在 Agent 設定的「記憶設定」中調整相關參數。

## 我需要做什麼？

1. **建立 Agent** — 取名、選擇語言模型
2. **寫角色指令** — 定義 Agent 的角色和回覆風格
3. **掛載能力** — 連結知識庫、工具、技能（視需求）
4. **測試對話** — 在內建的聊天視窗中測試效果
5. **串接平台上線** — 部署到 Web Chat、LINE 等對話平台

## 延伸閱讀

* [AI 助理的功能](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/blob/main/zh-tw/build/explain.md)
* [建立 AI 助理](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/blob/main/zh-tw/build/setup.md)
* [角色指令設計指南](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/blob/main/zh-tw/build/system-prompt.md)
* [為 AI 助理加入角色指令](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/blob/main/zh-tw/build/add-system-prompt.md)


---

# Agent Instructions: 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:

```
GET https://docs.maiagent.ai/agent-builder/agent.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
