> 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/schedule.md).

# 代理排程

代理排程是什麼：讓 Agent 定時自動執行任務（定時任務、主動發送通知），Cron／間隔／單次三種排程類型、執行模式與結果傳遞方式。

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-e9169408b97b414663b27cf64cdf81ba1b95f03e%2Fschedule-infographic.png?alt=media" alt="代理排程概念"><figcaption><p>代理排程：定時觸發 → Agent 自動執行 → 結果傳送</p></figcaption></figure>

## 這是什麼？ <a href="#what-is-this" id="what-is-this"></a>

代理排程讓 Agent 不用等人提問，能按照設定的時間自動執行任務。你給它一段提示詞，設定排程時間，Agent 就會定時執行並把結果送到指定的地方。

就像幫 Agent 設了一個鬧鐘——時間到了，它就自動開工。

## 什麼時候需要用？ <a href="#when-do-you-need-it" id="when-do-you-need-it"></a>

* **定期報告**：每天早上 9 點彙整昨日客服摘要
* **監控檢查**：每小時檢查一次系統狀態，有異常就通知
* **資料處理**：每週一整理上週的銷售數據
* **單次任務**：在指定時間執行一次特定動作

## 排程類型 <a href="#schedule-types" id="schedule-types"></a>

| 類型       | 說明               | 範例                        |
| -------- | ---------------- | ------------------------- |
| **Cron** | 用 Cron 表達式設定精確時間 | `0 9 * * 1-5`（週一到五早上 9 點） |
| **間隔**   | 每隔固定時間執行一次       | 每 30 分鐘、每 2 小時            |
| **單次執行** | 在指定時間執行一次        | 2026-04-15 14:00          |

## 執行模式 <a href="#execution-mode" id="execution-mode"></a>

| 模式        | 說明                 | 適合場景             |
| --------- | ------------------ | ---------------- |
| **上下文模式** | 跨次執行保留記憶，後一次能接續前一次 | 需要累積資訊的任務（如持續追蹤） |
| **獨立模式**  | 每次從頭開始，不帶前次記憶      | 獨立的重複性任務（如每日報告）  |

## 結果傳遞 <a href="#result-delivery" id="result-delivery"></a>

執行完成後，結果可以傳送到：

* **對話**：傳送到指定的對話平台對話中
* **Webhook**：POST 到你的外部 URL（串接 Slack、LINE 等）

> **進階說明**：代理排程只支援回答模式為 Agent 模式的 Agent。排程執行時，Agent 會以你設定的提示詞為指令，運用它掛載的所有工具和技能來完成任務。

排程執行的是一次「對話」，不是檔案批次處理：Agent 能做的事和你在對話中請它做的一樣。平台沒有內建「PDF 轉圖片」這類檔案轉換功能；要讓排程處理檔案，請讓 Agent 掛載能做這件事的能力——[Code Interpreter](/build/agent/code-interpreter.md) 可以在沙盒裡用程式處理知識庫或對話中的檔案並產出新檔案，需要固定串接外部系統時改用 [API 工具](/build/tools/setup_api_tool.md) 或 MCP 工具。處理結果以對話或 Webhook 送出，不會自動寫回知識庫。

## 我需要做什麼？ <a href="#what-do-i-need-to-do" id="what-do-i-need-to-do"></a>

1. **選擇 Agent** — 選一個已建好的 Agent（需為 Agent 模式）
2. **寫提示詞** — 描述 Agent 每次執行要做什麼
3. **設定排程** — 選擇排程類型和時間
4. **設定傳遞** — 決定結果要送去哪裡
5. **啟用** — 開啟排程，開始自動執行

## 下一步 <a href="#next-steps" id="next-steps"></a>

完整操作步驟請見 [如何設定代理排程](/build/agent/schedule/schedule-setup.md)。


---

# 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/schedule.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.
