Async Queue
A lightweight, file-backed task queue that fires delayed tasks to any OpenClaw agent at a scheduled time. Consists of four components:
| Component | What it does |
|---|
| daemon.js | Polls queue.json every 30s, delivers due tasks via the queue-wake plugin |
| push.js |
CLI to enqueue a new task with a delay |
|
queue-cli.js | CLI to list pending tasks, cancel by id prefix, and view history |
|
queue-wake plugin | OpenClaw plugin that receives delivery from daemon, enqueues a system event, and calls
requestHeartbeatNow for near-exact timing |
Installation (first time, macOS)
CODEBLOCK0
This will:
- 1. Copy
daemon.js + push.js to INLINECODE4 - Copy the
queue-wake plugin to INLINECODE6 - Register the daemon under launchd (auto-starts on login, auto-restarts on crash)
Then restart the OpenClaw gateway to activate the plugin:
openclaw gateway restart
Push a task
CODEBLOCK2
Arguments:
- -
--to — agent name (e.g. main). Can also be a full session key like agent:main:main. Optional; defaults to queue/config.json.defaultTo if set, else marcus. - INLINECODE12 — what the agent should do when this fires
- INLINECODE13 — how long from now:
10s, 5m, 2h, or absolute time: HH:MM (24h) / H:MMam (12h) - INLINECODE19 — optional chained task text to enqueue immediately after this task fires
- INLINECODE20 — (optional) seconds before item expires if undelivered (default: 300)
Examples:
# Remind in 30 minutes
node ~/.openclaw/queue/push.js --to main --task "Follow up: did the user save that document?" --delay 30m
# Check deploy health in 5 minutes
node ~/.openclaw/queue/push.js --to main --task "Verify deploy is healthy — check HTTP status" --delay 5m
# Fire today at 6:30 PM (or tomorrow if already past)
node ~/.openclaw/queue/push.js --task "Ping me before dinner" --delay 6:30pm
# Tonight reminder
node ~/.openclaw/queue/push.js --to main --task "Ask user about the pending decision" --delay 2h
# Chain a follow-up immediately after the first task fires
node ~/.openclaw/queue/push.js --task "Run deploy checks" --delay 10m --then "Verify logs are clean"
When to use this skill
Use async-queue when:
- - User asks to be reminded about something in X minutes/hours
- You spawn a sub-agent or background job and need to check back on it
- A follow-up needs to happen after a delay (e.g. verify a deploy, nudge a pending action)
- Any work that can't be completed this turn and needs to continue later
Don't use async-queue for:
- - Immediate actions → just do them
- Recurring schedules → use INLINECODE21
- Tasks waiting on user input → message the user directly
Schema
CODEBLOCK4
INLINECODE22 : seconds the item may remain undelivered before being dropped (default: 300s). Increase for tasks scheduled many hours out if the daemon might miss a window.
Delivery flow
CODEBLOCK5
Check queue state
CODEBLOCK6
Daemon status (macOS)
CODEBLOCK7
Files installed
| Path | Purpose |
|---|
| INLINECODE23 | Polling daemon |
| INLINECODE24 |
Push CLI |
|
~/.openclaw/queue/queue.json | Queue state file |
|
~/.openclaw/queue/daemon.log | Delivery log |
|
~/.openclaw/extensions/queue-wake/ | OpenClaw plugin |
|
~/Library/LaunchAgents/ai.openclaw.queue-daemon.plist | launchd service |
Protocol
See references/PROTOCOL.md for the full protocol: when to queue, rules, TTL guidance, and common task patterns.
异步队列
一个轻量级、基于文件的任务队列,能够在预定时间向任意OpenClaw代理触发延迟任务。由四个组件组成:
| 组件 | 功能说明 |
|---|
| daemon.js | 每30秒轮询queue.json,通过queue-wake插件投递到期任务 |
| push.js |
用于将新任务加入队列并设置延迟的命令行工具 |
|
queue-cli.js | 用于列出待处理任务、按ID前缀取消任务以及查看历史的命令行工具 |
|
queue-wake插件 | OpenClaw插件,接收守护进程的投递,将系统事件加入队列,并调用requestHeartbeatNow实现近乎精确的定时执行 |
安装(首次使用,macOS)
bash
bash $(openclaw skill path async-queue)/scripts/install.sh
此操作将:
- 1. 将daemon.js和push.js复制到~/.openclaw/queue/
- 将queue-wake插件复制到~/.openclaw/extensions/queue-wake/
- 在launchd下注册守护进程(登录时自动启动,崩溃时自动重启)
然后重启OpenClaw网关以激活插件:
bash
openclaw gateway restart
推送任务
bash
node ~/.openclaw/queue/push.js --task 描述 --delay <10s|5m|2h|HH:MM|H:MMam/pm> [--to ] [--then 下一个任务文本]
参数说明:
- - --to — 代理名称(例如main)。也可以是完整的会话键,如agent:main:main。可选参数;默认使用queue/config.json.defaultTo中的设置,若未设置则默认为marcus。
- --task — 任务触发时代理应执行的操作
- --delay — 从现在开始的延迟时间:10s、5m、2h,或绝对时间:HH:MM(24小时制)/ H:MMam(12小时制)
- --then — 可选参数,在此任务触发后立即加入队列的链式任务文本
- --ttl — (可选)项目未投递时的过期秒数(默认:300)
示例:
bash
30分钟后提醒
node ~/.openclaw/queue/push.js --to main --task 跟进:用户是否保存了那个文档? --delay 30m
5分钟后检查部署健康状态
node ~/.openclaw/queue/push.js --to main --task 验证部署是否正常——检查HTTP状态 --delay 5m
今天下午6:30触发(如果已过时则改为明天)
node ~/.openclaw/queue/push.js --task 晚饭前提醒我 --delay 6:30pm
今晚提醒
node ~/.openclaw/queue/push.js --to main --task 询问用户关于待定决策 --delay 2h
在第一个任务触发后立即链式执行后续任务
node ~/.openclaw/queue/push.js --task 运行部署检查 --delay 10m --then 验证日志是否正常
何时使用此技能
使用async-queue的场景:
- - 用户要求在X分钟/小时后提醒某件事
- 你生成了一个子代理或后台任务,需要稍后检查其状态
- 需要在延迟后执行后续操作(例如验证部署、催促待处理操作)
- 任何当前回合无法完成、需要稍后继续的工作
不要使用async-queue的场景:
- - 即时操作 → 直接执行即可
- 周期性任务 → 使用openclaw cron
- 等待用户输入的任务 → 直接向用户发送消息
数据模式
json
{
id: uuid,
to: agentId,
task: 字符串 — 触发时要执行的操作,
then: 字符串 — 可选,成功触发后加入队列的链式任务,
runAt: ISO 8601时间戳,
createdAt: ISO 8601时间戳,
ttl: 300
}
ttl:项目在未投递状态下可保留的秒数(默认:300秒)。对于计划在数小时后执行的任务,如果守护进程可能错过某个时间窗口,建议增加此值。
投递流程
push.js → queue.json → daemon.js(每30秒轮询)
→ POST /api/queue-wake(queue-wake插件)
→ enqueueSystemEvent([QUEUE:agentId] 任务)
→ requestHeartbeatNow(agentId)
→ 代理唤醒,在上下文中看到任务
检查队列状态
bash
cat ~/.openclaw/queue/queue.json # 待处理项目
node ~/.openclaw/queue/queue-cli.js list # 格式化列表
node ~/.openclaw/queue/queue-cli.js history # 最近20次投递记录
node ~/.openclaw/queue/queue-cli.js cancel
tail -20 ~/.openclaw/queue/daemon.log # 投递历史
守护进程状态(macOS)
bash
launchctl list | grep queue-daemon # 是否运行中?
如需重启:
launchctl unload ~/Library/LaunchAgents/ai.openclaw.queue-daemon.plist
launchctl load ~/Library/LaunchAgents/ai.openclaw.queue-daemon.plist
已安装文件
| 路径 | 用途 |
|---|
| ~/.openclaw/queue/daemon.js | 轮询守护进程 |
| ~/.openclaw/queue/push.js |
推送命令行工具 |
| ~/.openclaw/queue/queue.json | 队列状态文件 |
| ~/.openclaw/queue/daemon.log | 投递日志 |
| ~/.openclaw/extensions/queue-wake/ | OpenClaw插件 |
| ~/Library/LaunchAgents/ai.openclaw.queue-daemon.plist | launchd服务 |
协议
完整协议请参见references/PROTOCOL.md,包括:何时入队、规则、TTL指导原则以及常见任务模式。