当前位置: 首页 > Skill >

Autonomous Task Runner

Autonomous Task Runner

Autonomous Task Runner

持久化任务队列系统,支持随时通过自然语言添加任务,任务保存在单个持久化队列文件中并异步执行。

2.1.0 2026.11.12 107
获取Skill文件查看使用说明
作 者:周知 许可证: 更新时间:2026.11.12
本文目录展开

Task Runner Skill

A persistent, daemon-style task queue. Users add tasks at any time. A dispatcher runs on every heartbeat to check the queue and execute pending work via subagents. Tasks accumulate, complete, and are archived — the queue itself never closes.

Two Operating Modes

This skill has two distinct modes with different triggers and behaviors:

Mode Trigger Purpose
INTAKE User message containing task intent Parse message → add tasks to queue → confirm → immediately run DISPATCHER
DISPATCHER After INTAKE (primary) · Heartbeat/cron (backup) Read queue → dispatch pending tasks → report completions

Both modes read and write the same persistent queue file.

A1 — Triggers

Mode 1: INTAKE (user message)

Activate INTAKE mode when the user's message matches any of the following patterns:

Pattern Examples
Explicit task add "add task", "add these tasks", "task:", "new task"
Delegation "do this for me", "do these for me", "handle these", "can you do X"
Framing "I need you to", "help me with", "I need", "I want you to"
List framing "task list", "my tasks", "queue these", "work on these"
Control commands "skip T-03", "retry T-02", "mark T-01 done", "cancel T-04"
Status check "show tasks", "task status", "what's in the queue", "what are my pending tasks"
Compound ask Any message with 2+ distinct action items (bullets, numbers, "and also", "then")

Do NOT activate INTAKE for:

  • Pure single-question lookups answered in one sentence ("what time is it?")
  • Scheduling-only requests with no actual task ("remind me in 20 min")
  • Single web search requests ("google X")
  • The heartbeat systemEvent (that's DISPATCHER mode)

Mode 2: DISPATCHER (inline after INTAKE, heartbeat, or cron)

Activate DISPATCHER mode when triggered by:

  • Immediately after INTAKE — runs in the same turn, right after tasks are queued (primary path)
  • HEARTBEAT.md check during a heartbeat poll (backup: catches retries and completions)
  • systemEvent: "TASK_RUNNER_DISPATCH: check queue and run pending tasks" (backup)
  • Any scheduled/cron trigger registered for task-runner (backup)

Configuration

Variable Location Default Description
TASK_RUNNER_DIR TOOLS.md ~/.openclaw/tasks/ Directory for queue file and deliverables
TASK_RUNNER_MAX_CONCURRENT TOOLS.md 2 Max tasks running simultaneously
TASK_RUNNER_MAX_RETRIES TOOLS.md or env 3 Max retry attempts before marking blocked
TASK_RUNNER_ARCHIVE_DAYS TOOLS.md 7 Days after which done/blocked tasks are archived

How to configure — add to TOOLS.md:

## Task Runner
TASK_RUNNER_DIR=~/.openclaw/tasks/
TASK_RUNNER_MAX_CONCURRENT=2
TASK_RUNNER_MAX_RETRIES=3
TASK_RUNNER_ARCHIVE_DAYS=7

Queue file path: ${TASK_RUNNER_DIR}/task-queue.json (single persistent file, NOT dated — accumulates all tasks over time)

A3 — Outputs

Output Path / Channel Description
Queue file ${TASK_RUNNER_DIR}/task-queue.json Single persistent queue; all tasks
Per-task completion message Chat notification Sent immediately when a task finishes (done or blocked)
Deliverable files Task-specific paths Files produced by tasks (when applicable)
INTAKE confirmation Chat Sent after adding tasks to queue

Mode 1: INTAKE — Step-by-Step

Goal: Convert user message into structured task objects, append to queue, confirm.

Step 0 — First Run Setup (auto-configure on first use)

Run this check before anything else, every INTAKE invocation:

CHECK whether ${TASK_RUNNER_DIR}/task-queue.json exists
IF file does NOT exist:
  → This is the first run. Auto-configure everything silently before proceeding.

  [1] Create directory:
      exec: mkdir -p ${TASK_RUNNER_DIR}

  [2] Initialize queue file:
      WRITE ${TASK_RUNNER_DIR}/task-queue.json with default structure:
      { "lastId": null, "tasks": [], "archivedCount": 0 }

  [3] Register heartbeat entry:
      READ HEARTBEAT.md (create it if missing)
      IF "Task Runner Dispatcher" is NOT already in the file:
        APPEND the following block (with a blank line before it):

        ## Task Runner Dispatcher
        Every heartbeat: check ${TASK_RUNNER_DIR}/task-queue.json
        - If pending or running tasks exist → run DISPATCHER mode (task-runner skill)
        - If nothing pending → HEARTBEAT_OK (skip)

      WRITE the updated HEARTBEAT.md

  [4] Register backup cron job:
      CALL cron tool with:
        action: "add"
        job:
          name: "Task Runner Dispatcher"
          schedule: { kind: "every", everyMs: 900000 }
          payload: { kind: "systemEvent", text: "TASK_RUNNER_DISPATCH: check queue and run pending tasks" }
          sessionTarget: "main"
          enabled: true

  [5] Notify user:
      "⚙️ Task Runner initialized.
       Heartbeat dispatcher registered in HEARTBEAT.md.
       Backup cron job registered (runs every 15 minutes).
       Your tasks will execute automatically."

  → THEN continue with normal INTAKE steps below.

IF file already exists:
  → Skip Step 0 entirely. Proceed directly to Step 1.

Idempotency rule: Step 0 only fires on true first run (queue file absent). It will never double-register the heartbeat entry or create duplicate cron jobs.

Step 1 — Load queue

READ ${TASK_RUNNER_DIR}/task-queue.json
IF file does not exist:
  Initialize with default structure (see references/queue-schema.md)
  Set lastId = null

Step 2 — Parse tasks from message

Split user message into individual tasks using these cues:

  • Numbered lists (1., 2., 3.)
  • Bulleted lists (-, *, •)
  • Explicit separators ("first", "also", "and then", "next")
  • Compound sentences with multiple imperatives
  • Single task: entire message is one task

Step 3 — Assign IDs

Continue from lastId in the queue file:

  • If lastId = "T-05", next task is T-06
  • If lastId = null, start at T-01
  • Format: T-NN (zero-padded, minimum 2 digits; expand to 3 when N > 99)

Step 4 — Build task objects

For each parsed task, create a JSON object (schema in references/queue-schema.md):

  • Set id, description, goal, status = "pending", added_at
  • Set retries = 0, maxRetries from config
  • Leave execution fields null

Step 5 — Append to queue and save

APPEND new task objects to queue.tasks[]
UPDATE queue.lastId to the last assigned ID
WRITE updated queue file to disk

Step 6 — Confirm to user

Added T-06: [description]. Starting now...

For multiple tasks:

📋 Added 3 tasks to queue:
• T-06: [description]
• T-07: [description]
• T-08: [description]
Starting dispatcher now...

Then immediately run DISPATCHER mode (Steps 1–5 below) in the same turn. Do not exit and wait for the next heartbeat. Tasks must start executing immediately. The heartbeat/cron dispatcher is a backup for retries and completion checks — not the primary execution path.

Step 7 — Handle control commands

Command Action
skip T-NN Set status = "skipped"; save; confirm
retry T-NN Reset status = "pending", retries = 0; save; confirm
cancel T-NN Set status = "skipped", blocked_reason = "cancelled by user"; save; confirm
mark T-NN done Set status = "done", completed_at = now; save; confirm
show tasks / task status Read queue; render status table (see A5 templates)

Mode 2: DISPATCHER — Step-by-Step

Goal: Check queue, dispatch pending tasks, track running tasks, report completions.

Step 1 — Load queue

READ ${TASK_RUNNER_DIR}/task-queue.json
IF file does not exist OR tasks array is empty:
  → HEARTBEAT_OK (silent, nothing to do)
  → EXIT

Step 2 — Check for work

pending_tasks = tasks where status = "pending"
running_tasks = tasks where status = "running"

IF pending_tasks is empty AND running_tasks is empty:
  → HEARTBEAT_OK (silent)
  → EXIT

Step 3 — Check running tasks for completion

For each task with status = "running":

IF subagent_session is set:
  CHECK subagent session status

  IF session is DONE:
    READ deliverable from session output
    RUN verification (see references/verification-guide.md)
    IF verification passes:
      SET status = "done"
      SET deliverable, deliverable_path, completed_at
      NOTIFY user: ✅ T-NN done — [summary]
    ELSE (verification failed):
      TREAT as failure (see retry logic below)

  IF session is FAILED or ERROR:
    IF retries < maxRetries:
      INCREMENT retries
      ADD to strategies_tried
      SET status = "pending"  ← will be re-dispatched this cycle
    ELSE:
      SET status = "blocked"
      SET blocked_reason, user_action_required, completed_at
      NOTIFY user: 🚫 T-NN blocked — [reason + unblock steps]

  IF session is STILL RUNNING:
    Leave as-is (will check again next heartbeat)

Step 4 — Dispatch pending tasks

currently_running = count of tasks with status = "running"
slots_available = maxConcurrent - currently_running

FOR EACH pending task (in order of added_at), up to slots_available:
  PICK execution strategy (see references/task-types.md)
  SPAWN subagent with task description and strategy
  SET status = "running"
  SET subagent_session = spawned session ID
  SET started_at = now

Subagent instructions template:

You are executing task [T-NN] for the task-runner skill.

Task: [description]
Goal: [goal]
Type: [task_type]
Strategy: [selected strategy from task-types.md]

Execute the task. When complete:
1. Report the result clearly
2. Note any deliverable file path if a file was created
3. If blocked, explain exactly why and what the user needs to do

Do not start any other tasks. Focus only on this one.

Step 5 — Save and exit

WRITE updated queue file (status changes, subagent_session IDs)

If any notifications were sent (done/blocked), this is an active heartbeat response. If only silent dispatching occurred, this is still a heartbeat response (not HEARTBEAT_OK). Only return HEARTBEAT_OK when there was truly nothing to do (no pending, no running tasks).

A5 — Output Format Templates

INTAKE confirmation (single task)

Added T-06: [description]. Queue now has N pending tasks.

INTAKE confirmation (multiple tasks)

📋 Added N tasks to queue:
• T-06: [description]
• T-07: [description]

Starting now...

Task status table (on demand)

📋 Task Queue — [N total, N pending, N running, N done, N blocked]

ID    Status      Description
T-01  ✅ done      [description] → [deliverable summary]
T-02  🔄 running   [description] (started [time ago])
T-03  ⏳ pending   [description]
T-04  🚫 blocked   [description] — [blocked_reason short]
T-05  ⏭️ skipped   [description]

Task done notification

✅ T-NN done — [one-sentence summary of what was accomplished]
[deliverable: link or file path, if applicable]

Task blocked notification

🚫 T-NN blocked after [N] attempts

What was tried:
- [Strategy 1]: [result]
- [Strategy 2]: [result]

Why it's blocked:
[Clear plain-English explanation]

To unblock:
1. [Concrete step #1]
2. [Concrete step #2 if needed]

Reply "retry T-NN" once ready.

Task skipped

⏭️ T-NN skipped — as requested.

A6 — Heartbeat Integration

Heartbeat and cron setup is automatic. Step 0 of INTAKE mode handles this on first use — no manual configuration required.

Role of heartbeat/cron (backup only)

Tasks are dispatched immediately after INTAKE — heartbeat and cron are backups only.

The backup dispatcher handles:

  • Retry dispatch: tasks that failed and were reset to pending
  • Completion checks: polling running subagent sessions for done/blocked status
  • Recovery: tasks that were pending when no user message triggered INTAKE

Users should never need to wait for a heartbeat for a freshly added task.

What gets configured automatically

HEARTBEAT.md entry (injected on first INTAKE):

## Task Runner Dispatcher
Every heartbeat: check ${TASK_RUNNER_DIR}/task-queue.json
- If pending or running tasks exist → run DISPATCHER mode (task-runner skill)
- If nothing pending → HEARTBEAT_OK (skip)

Backup cron job (registered on first INTAKE):

every 15 min → systemEvent: "TASK_RUNNER_DISPATCH: check queue and run pending tasks"
sessionTarget: main

Manual setup (if needed)

If for any reason auto-setup did not run (e.g., queue file was pre-created externally), delete ${TASK_RUNNER_DIR}/task-queue.json and send any task — Step 0 will fire.

A7 — Success Criteria

INTAKE mode succeeds when:

  1. All tasks from user message parsed and assigned IDs
  2. Tasks appended to queue file (file saved to disk)
  3. Confirmation sent to user with task IDs and count
  4. DISPATCHER mode triggered immediately in the same turn
  5. Subagents spawned for pending tasks before INTAKE turn ends

DISPATCHER mode succeeds when:

  1. Queue file read without error
  2. All running tasks checked for completion (done/blocked notifications sent as needed)
  3. Pending tasks dispatched up to maxConcurrent slots
  4. Queue file saved with updated states
  5. User notified for every task that reached a terminal state this cycle

Ongoing system health:

  • Queue file is never corrupted (always valid JSON)
  • Tasks older than archiveDays days with terminal status are archived/removed
  • lastId always increments (no ID reuse)
  • maxRetries respected before any task is marked blocked

Edge Cases

Situation Behavior
Queue file missing (first run) Run Step 0 auto-setup: create dir, init queue, register heartbeat + cron; notify user
Queue file missing (manually deleted) Step 0 re-fires: re-initializes queue; does NOT re-register heartbeat/cron (idempotent check)
Queue file corrupt/invalid JSON Log error, notify user, do not overwrite; ask user to inspect
Task description is ambiguous Assign unknown type; dispatcher will attempt classification + fallback
maxConcurrent already reached Dispatcher skips dispatching; checks again next heartbeat
User adds task while dispatcher is running Race-safe: dispatcher reads, processes, writes atomically per cycle
Task depends on another task's output Set blocked_reason = "depends on T-NN-1 which is pending/blocked"
User says "retry T-NN" Reset to pending, retries = 0, strategies_tried = []
All tasks blocked Notify user: "All tasks are blocked. Review unblock instructions above."
20+ tasks added at once Dispatcher dispatches in batches of maxConcurrent; all tasks eventually run
Subagent session ID lost Mark task as pending again; will re-dispatch next cycle
Archive: done tasks > archiveDays old Move to ${TASK_RUNNER_DIR}/archive/YYYY-MM.json; remove from main queue

A8 — File Organization

${TASK_RUNNER_DIR}/
  task-queue.json          ← single persistent queue (all active tasks)
  archive/
    2026-01.json           ← archived tasks (done/blocked, older than archiveDays)
    2026-02.json

Queue file schema is documented in references/queue-schema.md.

References

  • references/queue-schema.md — Queue JSON format (complete field reference)
  • references/task-types.md — Task type catalog and strategy selection
  • references/verification-guide.md — Verification logic per task type
  • tests/test-triggers.json — Trigger test cases (positive and negative)

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,040
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,033
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,021
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,021
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,019
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,016
Skill 文件
  • SKILL.md
    • Task Runner Skill
    • Two Operating Modes
    • A1 — Triggers
      • Mode 1: INTAKE (user message)
      • Mode 2: DISPATCHER (inline after INTAKE, heartbeat, or cron)
    • Configuration
    • A3 — Outputs
    • Mode 1: INTAKE — Step-by-Step
      • Step 0 — First Run Setup (auto-configure on first use)
      • Step 1 — Load queue
      • Step 2 — Parse tasks from message
      • Step 3 — Assign IDs
      • Step 4 — Build task objects
      • Step 5 — Append to queue and save
      • Step 6 — Confirm to user
      • Step 7 — Handle control commands
    • Mode 2: DISPATCHER — Step-by-Step
      • Step 1 — Load queue
      • Step 2 — Check for work
      • Step 3 — Check running tasks for completion
      • Step 4 — Dispatch pending tasks
      • Step 5 — Save and exit
    • A5 — Output Format Templates
      • INTAKE confirmation (single task)
      • INTAKE confirmation (multiple tasks)
      • Task status table (on demand)
      • Task done notification
      • Task blocked notification
      • Task skipped
    • A6 — Heartbeat Integration
      • Role of heartbeat/cron (backup only)
      • What gets configured automatically
      • Manual setup (if needed)
    • A7 — Success Criteria
      • INTAKE mode succeeds when:
      • DISPATCHER mode succeeds when:
      • Ongoing system health:
    • Edge Cases
    • A8 — File Organization
    • References
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期