2026.4.1 新增功能:聊天原生的后台任务管理界面
📋 什么是任务看板?
任务看板是 OpenClaw 2026.4.1 引入的新功能,提供一个聊天原生的界面来查看和管理后台任务。
主要用途:
- 查看当前会话的后台任务状态
- 追踪长时间运行的任务进度
- 管理任务通知策略
- 清理过期/失败的任务
🚀 如何使用任务看板
方法 1:聊天命令(推荐)
在聊天中发送:
/tasks
适用场景:
- ✅ Discord/Telegram/Slack 等聊天通道
- ✅ WebChat 界面
- ✅ 任何可以发送消息的通道
输出示例:
📋 任务看板 - 当前会话
🟢 运行中 (1)
└─ [任务 ID] 任务描述 - 已运行 5m
✅ 已完成 (3)
└─ [任务 ID] 任务描述 - 2 分钟前完成
❌ 失败 (0)
方法 2:CLI 命令
# 查看任务列表
openclaw tasks list
# 查看任务列表(JSON 格式)
openclaw tasks list --json
# 按运行时过滤
openclaw tasks list --runtime subagent
openclaw tasks list --runtime acp
openclaw tasks list --runtime cron
openclaw tasks list --runtime cli
# 按状态过滤
openclaw tasks list --status running
openclaw tasks list --status queued
openclaw tasks list --status failed
openclaw tasks list --status succeeded
# 查看单个任务详情
openclaw tasks show <task-id>
# 取消运行中的任务
openclaw tasks cancel <task-id>
# 查看过期/损坏的任务
openclaw tasks audit
# 设置任务通知策略
openclaw tasks notify <policy>
📊 任务状态说明
| 状态 | 说明 | 图标 |
|---|---|---|
queued |
等待执行 | ⏳ |
running |
正在运行 | 🟢 |
succeeded |
成功完成 | ✅ |
failed |
执行失败 | ❌ |
timed_out |
超时 | ⏱️ |
cancelled |
已取消 | 🚫 |
lost |
丢失(异常状态) | ❓ |
🔍 查看任务详情
通过 CLI 查看
# 显示任务详情
openclaw tasks show <task-id>
# 显示任务详情(JSON 格式)
openclaw tasks show <task-id> --json
通过聊天查看
在聊天中发送:
/tasks show <task-id>
📁 任务数据存储
存储位置: ~/.openclaw/tasks/runs.sqlite
相关文件:
| 文件 | 说明 |
|---|---|
runs.sqlite |
主数据库文件 |
runs.sqlite-shm |
共享内存文件 |
runs.sqlite-wal |
预写日志文件 |
注意: 不要直接修改这些文件,使用 CLI 命令管理。
⚙️ 任务类型
| 类型 | 说明 | 示例 |
|---|---|---|
subagent |
子代理任务 | 代码分析、文档生成 |
acp |
ACP 编码会话 | Codex/Cursor 会话 |
cron |
定时任务 | 每日备份、定时提醒 |
cli |
CLI 触发的任务 | 手动执行的任务 |
🔧 常用命令速查
查看任务
# 查看所有任务
openclaw tasks list
# 查看运行中的任务
openclaw tasks list --status running
# 查看失败的任务
openclaw tasks list --status failed
# 查看特定类型的任务
openclaw tasks list --runtime cron
管理任务
# 取消任务
openclaw tasks cancel <task-id>
# 查看任务详情
openclaw tasks show <task-id>
# 清理过期任务
openclaw tasks maintenance --apply
审计和维护
# 查看过期/损坏的任务
openclaw tasks audit
# 预览维护操作
openclaw tasks maintenance
# 应用维护操作
openclaw tasks maintenance --apply
💡 使用技巧
1. 在聊天中快速查看
/tasks
这会显示当前会话的任务摘要,包括:
- 运行中的任务数量
- 最近完成的任务
- 失败的任务(如有)
2. 过滤特定状态
# 只看失败的任务
openclaw tasks list --status failed
# 只看运行中的任务
openclaw tasks list --status running
3. 导出任务数据
# 导出为 JSON
openclaw tasks list --json > tasks.json
# 处理 JSON 数据
cat tasks.json | jq '.[] | select(.status == "failed")'
4. 设置通知策略
# 设置任务完成时通知
openclaw tasks notify on-exit
# 设置仅在失败时通知
openclaw tasks notify on-failure
# 关闭通知
openclaw tasks notify off
❓ 常见问题
Q1: /tasks 命令不响应怎么办?
A: 可能是任务数据库锁定了。尝试:
# 重启 Gateway
openclaw gateway restart
# 或者使用 CLI 命令
openclaw tasks list
Q2: 如何查看其他会话的任务?
A: 任务看板默认显示当前会话的任务。查看其他会话需要:
# 使用 sessionKey 过滤(需要知道会话 ID)
openclaw tasks list --session <session-key>
Q3: 任务数据会保存多久?
A: 默认情况下,任务数据会永久保存。可以定期运行维护命令清理:
# 预览可清理的任务
openclaw tasks maintenance
# 应用清理
openclaw tasks maintenance --apply
Q4: 如何在 Discord 中使用任务看板?
A: 在 Discord 通道中发送 /tasks 即可。确保:
- Bot 有发送消息权限
- 通道允许 Bot 发送嵌入消息
Q5: 任务看板支持哪些通道?
A: 所有支持聊天命令的通道:
- ✅ Discord
- ✅ Telegram
- ✅ Slack
- ✅ WebChat
- ✅ QQ Bot