Autonomous Loop
Keeps an OpenClaw agent working continuously without human intervention. After each reply, the plugin waits N seconds and automatically sends the next task instruction — until you place a stop file.
Installation
CODEBLOCK0
Verify it loaded:
CODEBLOCK1
If not shown, restart the Gateway: INLINECODE0
How It Works
CODEBLOCK2
Logs are written to: INLINECODE1
Configuration
Add to ~/.openclaw/openclaw.json under the plugins key:
CODEBLOCK3
| Parameter | Type | Description |
|---|
| INLINECODE4 | number | Milliseconds to wait before sending the next message (default: 30000) |
| INLINECODE5 |
string | Fallback message used when no per-agent message is configured |
|
agents | object | Per-agent messages. Key = agentId, value = message string |
Stop & Resume
CODEBLOCK4
Log Reference
| Log entry | Meaning |
|---|
| INLINECODE7 | Normal — reply finished, countdown running |
| INLINECODE8 |
Normal — message delivered, next round started |
|
stop-file-detected | Stop file found by watcher, loop paused |
|
skipped-stop-flag | Stop file present at trigger time, skipped |
|
send-error | Message delivery failed — check if gateway is running |
|
skipped-no-assistant-text | Agent reply had no text content, skipped |
|
skipped-no-gateway-config | Gateway port or token missing from config |
|
skipped-stop-token | Agent replied with DONE or HEARTBEAT_OK — loop idle until next user message |
Agent Workspace Structure
A workspace for an autonomous agent needs these files:
CODEBLOCK5
Session startup sequence (defined in WORK.md):
CODEBLOCK6
Two-Phase Workflow for New Projects
Long-running agents restart fresh every session. Structure work in two phases:
Phase 1 — Init session (first session only)
- 1. Create
init.sh — one command to start the dev server - Create
FEATURES.json — full feature list, every item INLINECODE17 - First git commit
- Write each feature as a sub-task in TASKS.md
Phase 2 — Coding sessions (every subsequent session)
- - Read git log + PROGRESS.md to restore context
- Do one feature per session
- Only mark
"status": "passing" after E2E verification - Never delete or modify tests to make them pass
FEATURES.json Pattern (Large Projects)
For projects with 10+ independent features, track verification state in a structured JSON file instead of a plain checklist:
CODEBLOCK7
Each session picks one "failing" item, implements and verifies it, then updates status to "passing".
Difference from agent-reply-trigger
If you already have the agent-reply-trigger plugin installed, this skill provides equivalent functionality with external configuration instead of hardcoded values.
| agent-reply-trigger | autonomous-loop (this skill) |
|---|
| Message config | Hardcoded in index.ts | Configured in config.json |
| Log prefix |
agent-reply-trigger- |
autonomous-loop- |
| Stop file |
agent-reply-trigger.{id}.stop |
autonomous-loop.{id}.stop |
Do not enable both plugins for the same agentId — the loop will fire twice per reply.
Autonomous Loop
让 OpenClaw 智能体无需人工干预即可持续工作。每次回复后,插件会等待 N 秒并自动发送下一个任务指令——直到你放置一个停止文件。
安装
bash
将插件复制到 OpenClaw 的扩展目录
cp -r ~/.openclaw/skills/local/autonomous-loop/plugin \
~/.openclaw/extensions/autonomous-loop
验证加载成功:
bash
openclaw plugins info autonomous-loop
openclaw gateway status
如果未显示,请重启 Gateway:openclaw gateway restart
工作原理
智能体完成回复
│
▼
[agent_end 事件] ← 插件在此监听
│
├─ 停止文件存在?→ 跳过本轮
│
▼
等待 delayMs(默认 30 秒)
│
├─ 再次检查停止文件(双重检查)
│
▼
通过 WebSocket 向同一会话发送下一个任务消息
│
▼
智能体开始下一轮工作 ────────────────────────↑ 循环
日志写入:~/.openclaw/logs/autonomous-loop-{agentId}.log
配置
在 ~/.openclaw/openclaw.json 的 plugins 键下添加:
json
{
plugins: {
autonomous-loop: {
delayMs: 30000,
defaultMessage: 读取 TASKS.md 和 PROGRESS.md。选择优先级最高的待处理任务并执行。完成后更新两个文件。,
agents: {
david: 读取 TASKS.md 和 PROGRESS.md 了解当前项目状态,然后:\n\n1. 如果有进行中的任务,继续执行\n2. 否则选择优先级最高的待处理任务(跳过需要用户输入的任务)\n3. 执行任务,通过端到端浏览器测试验证,截图作为证据\n4. 更新 TASKS.md 和 PROGRESS.md,
allen: 读取 Todo.md。选择优先级最高的未完成任务并执行。完成后更新 Todo.md。
}
}
}
}
| 参数 | 类型 | 描述 |
|---|
| delayMs | number | 发送下一条消息前的等待毫秒数(默认:30000) |
| defaultMessage |
string | 未配置每个智能体消息时使用的后备消息 |
| agents | object | 每个智能体的消息。键 = agentId,值 = 消息字符串 |
停止与恢复
bash
暂停特定智能体的循环
touch ~/.openclaw/autonomous-loop.{agentId}.stop
恢复循环
rm ~/.openclaw/autonomous-loop.{agentId}.stop
实时查看循环日志
tail -f ~/.openclaw/logs/autonomous-loop-{agentId}.log
日志参考
| 日志条目 | 含义 |
|---|
| countdown-started | 正常——回复完成,倒计时运行中 |
| message-sent |
正常——消息已发送,下一轮开始 |
| stop-file-detected | 观察器发现停止文件,循环暂停 |
| skipped-stop-flag | 触发时停止文件存在,已跳过 |
| send-error | 消息发送失败——检查 gateway 是否运行 |
| skipped-no-assistant-text | 智能体回复无文本内容,已跳过 |
| skipped-no-gateway-config | 配置中缺少 Gateway 端口或令牌 |
| skipped-stop-token | 智能体回复 DONE 或 HEARTBEAT_OK——循环空闲直到下一条用户消息 |
智能体工作空间结构
自主智能体的工作空间需要以下文件:
workspace-{agentId}/
├── AGENTS.md # 启动序列、记忆系统、行为规则
├── SOUL.md # 身份和核心价值观
├── WORK.md # 执行循环(选择任务 → 执行 → 验证 → 收尾)
├── TASKS.md # 任务队列(待处理 / 进行中 / 已完成)
├── PROGRESS.md # 项目状态——每次会话结束时必须更新
├── HEARTBEAT.md # 心跳检查清单(空文件 = 跳过)
└── ARTIFACTS/ # 工作产出(截图、代码、分析)
会话启动序列(在 WORK.md 中定义):
- 1. git log --oneline -20 了解最近做了什么
- 读取 PROGRESS.md 当前项目状态
- 读取 TASKS.md 找到下一个任务
- 运行 init.sh(如果存在) 启动开发服务器
- 基本 E2E 测试 捕获上次会话遗留的 bug
- 选择一个任务,执行一个任务
新项目的两阶段工作流
长时间运行的智能体每次会话都会重新启动。将工作分为两个阶段:
阶段 1 — 初始化会话(仅第一次会话)
- 1. 创建 init.sh — 启动开发服务器的单个命令
- 创建 FEATURES.json — 完整功能列表,每个项目 status: failing
- 第一次 git 提交
- 将每个功能作为子任务写入 TASKS.md
阶段 2 — 编码会话(每次后续会话)
- - 读取 git log + PROGRESS.md 恢复上下文
- 每次会话完成一个功能
- 仅在 E2E 验证后标记 status: passing
- 绝不删除或修改测试使其通过
FEATURES.json 模式(大型项目)
对于有 10 个以上独立功能的项目,使用结构化 JSON 文件而非纯文本清单跟踪验证状态:
json
[
{ id: user-login, description: 用户登录, status: passing, verified: 2026-03-20 },
{ id: video-upload, description: 视频上传, status: failing, verified: null }
]
每次会话选择一个 failing 项目,实现并验证,然后将 status 更新为 passing。
与 agent-reply-trigger 的区别
如果你已经安装了 agent-reply-trigger 插件,本技能提供相同的功能,但使用外部配置而非硬编码值。
| agent-reply-trigger | autonomous-loop(本技能) |
|---|
| 消息配置 | 在 index.ts 中硬编码 | 在 config.json 中配置 |
| 日志前缀 |
agent-reply-trigger- | autonomous-loop- |
| 停止文件 | agent-reply-trigger.{id}.stop | autonomous-loop.{id}.stop |
不要为同一个 agentId 同时启用两个插件——否则每次回复会触发两次循环。