---
name: schedule-job
description: Scheduled Task Management - Create, manage, and view scheduled tasks for users (supports cron recurring tasks and one-time tasks)
---

# Schedule Job - Scheduled Task Management

Manage scheduled tasks for users, supporting cron recurring tasks and one-time scheduled tasks. The system automatically executes AI conversations when tasks are due.

## Quick Start

When a user requests to create a scheduled task:
1. Confirm the task type (recurring cron / one-time once)
2. Determine the time (cron expression or specific time) and timezone
3. Confirm notification method: Check the currently enabled skills in the context and recommend a suitable notification method to the user (e.g., email, Telegram, etc.) for confirmation. If no notification skills are available, proactively ask the user: "How would you like to be notified when the scheduled task completes?"
4. Compose the message content to send to the AI (refer to Message Writing Guidelines)
5. Call schedule_manager.py to create the task

## Instructions

### Tool Path

All operations are executed via shell commands:
```bash
python {skill_dir}/scripts/schedule_manager.py <command> [options]
```

### Available Commands

#### List Tasks
```bash
python {skill_dir}/scripts/schedule_manager.py list
python {skill_dir}/scripts/schedule_manager.py list --format brief
```

#### Add Cron Recurring Task
```bash
python {skill_dir}/scripts/schedule_manager.py add \
  --name "Task Name" \
  --type cron \
  --schedule "0 9 * * *" \
  --timezone "Asia/Tokyo" \
  --message "[Scheduled Task Triggered] Please execute the following task immediately: Search and summarize today's important tech news, listing the Top 5 in a concise format. After completion, select an appropriate notification method based on the currently enabled skills to push the results to the user."
```

#### Add One-Time Task
```bash
python {skill_dir}/scripts/schedule_manager.py add \
  --name "Meeting Reminder" \
  --type once \
  --scheduled-at "2026-04-01T10:00:00+09:00" \
  --message "[Scheduled Task Triggered] A scheduled reminder has arrived. The schedule content is: 'Meeting at 10:00'. Please compose an appropriate reminder message based on the schedule content, then select an appropriate notification method based on the currently enabled skills to send the reminder to the user."
```

#### Edit Task
```bash
python {skill_dir}/scripts/schedule_manager.py edit <task_id> \
  --schedule "0 10 * * 1-5" \
  --message "New message content"
```

#### Delete Task
```bash
python {skill_dir}/scripts/schedule_manager.py delete <task_id>
```

#### Pause/Resume Task
```bash
python {skill_dir}/scripts/schedule_manager.py toggle <task_id>
```

#### View Execution Logs
```bash
python {skill_dir}/scripts/schedule_manager.py logs --limit 10
python {skill_dir}/scripts/schedule_manager.py logs --task-id <task_id>
```

### Timezone Mapping

Automatically recommend timezone based on user language:
- Chinese (zh) → Asia/Shanghai (UTC+8)
- Japanese (ja/jp) → Asia/Tokyo (UTC+9)
- English (en) → UTC

### Cron Expression Reference

Standard 5-field format: `minute hour day-of-month month day-of-week`

Common examples:
| Expression | Meaning |
|-----------|---------|
| `0 9 * * *` | Every day at 9:00 |
| `0 9 * * 1-5` | Monday to Friday at 9:00 |
| `30 8 * * 1` | Every Monday at 8:30 |
| `0 */2 * * *` | Every 2 hours |
| `0 9,18 * * *` | Every day at 9:00 and 18:00 |

**Note**: Cron expression times are based on the timezone specified by --timezone.

### One-Time Task Time Format

Supports ISO 8601 format (timezone offset recommended):
- `2026-04-01T10:00:00+09:00` (Japan Time)
- `2026-04-01T01:00:00Z` (UTC)
- `2026-04-01T08:00:00+08:00` (China Time)

## Message Writing Guidelines

The message is an execution instruction sent to the AI agent when the scheduled task triggers. The agent has no conversation context at execution time, so the message must include:

1. **Task Trigger Indicator**: Start with "[Scheduled Task Triggered]" (or equivalent in the user's language) to clearly indicate this is a triggered scheduled task execution, NOT a request to create a task
2. **Task Content**: What specifically needs to be done (use imperative verbs like "Please execute immediately", "Please do")
3. **Notification Instruction**: Based on the notification method confirmed by the user, explicitly specify the notification channel in the message (e.g., "notify the user via email"). If the user has not specified, write "select an appropriate notification method based on the currently enabled skills to push the results to the user"
4. **Language**: The message language must match the language the user is currently using in the conversation (e.g., if the user speaks Japanese, write the message in Japanese)

### Important: Avoid Ambiguity

The message will be executed by an AI agent when the scheduled time arrives. The message must clearly indicate this is an **execution instruction**, not a request to **create a scheduled task**.

### Schedule Reminder Scenario (One-Time Task)

❌ Wrong: `"Reminder: You have a meeting to attend now, don't forget!"`

❌ Wrong: `"It's tomorrow at 3 PM, please remind the user to attend the meeting"` (Agent will think this is a request to create a reminder)

✅ Correct: `"[Scheduled Task Triggered] A scheduled reminder has arrived. The schedule content is: 'Product review meeting at 3:00 PM'. Please compose an appropriate reminder message based on the schedule content, then select an appropriate notification method based on the currently enabled skills to send the reminder to the user."`

### Recurring Task Scenario (Cron Task)

❌ Wrong: `"It's 8:40 PM every day, please remind the user to write a daily report. Please send message via Lark Webhook, Webhook URL: xxx"` (Agent will think this is a request to create a daily task)

❌ Wrong: `"Execute: Get latest news"`

✅ Correct: `"[Scheduled Task Triggered] Please execute the following task immediately: Search and summarize today's important tech news, listing the Top 5 in a concise format. After completion, select an appropriate notification method based on the currently enabled skills to push the results to the user."`

✅ Correct: `"[Scheduled Task Triggered] This is a daily reminder task. Please execute immediately: Remind the user to write a daily report. Please send the message via Lark Webhook, Webhook URL: xxx"`

## Examples

**User**: "Set up a daily news summary task at 9 AM"

```bash
python {skill_dir}/scripts/schedule_manager.py add \
  --name "Daily News Summary" \
  --type cron \
  --schedule "0 9 * * *" \
  --timezone "Asia/Tokyo" \
  --message "[Scheduled Task Triggered] Please execute the following task immediately: Search and summarize today's important tech news, listing the Top 5 in a concise format. After completion, select an appropriate notification method based on the currently enabled skills to push the results to the user."
```

**User**: "Remind me about the meeting tomorrow at 3 PM"

```bash
python {skill_dir}/scripts/schedule_manager.py add \
  --name "Meeting Reminder" \
  --type once \
  --scheduled-at "2026-04-01T15:00:00+09:00" \
  --message "[Scheduled Task Triggered] A scheduled reminder has arrived. The schedule content is: 'Meeting at 3:00 PM'. Please compose an appropriate reminder message based on the schedule content, then select an appropriate notification method based on the currently enabled skills to send the reminder to the user."
```

**User**: "Change the daily news task to 10 AM"

```bash
# First check the task list to get the task_id
python {skill_dir}/scripts/schedule_manager.py list
# Then edit
python {skill_dir}/scripts/schedule_manager.py edit <task_id> --schedule "0 10 * * *"
```

## Guidelines

- Before creating a task, use `list` to check existing tasks and avoid duplicates
- Automatically set the appropriate timezone based on user language
- **Must confirm notification method before creating a task**: Check the currently enabled skills, recommend available notification channels to the user and confirm. If no notification skills are available, proactively ask the user how they would like to receive results
- Message content is a complete execution instruction for the AI agent and must include both task content and notification instructions (refer to the Message Writing Guidelines above)
- The message language must match the language the user is currently using in the conversation
- One-time task times cannot be in the past
- When editing a task, only modify the fields the user requested — do not change other fields
