Xpersona
C

Complex Task Subagent

CLAWHUB · Unverified

Complex task orchestration and subagent command framework. Execute multi-stage complex tasks via subagent (sessions_spawn), including task breakdown, state m... Skill: Complex Task Subagent Owner: miyan1221 Summary: Complex task orchestration and subagent command framework. Execute multi-stage complex tasks via subagent (sessions_spawn), including task breakdown, state m... Tags: latest:2.0.1 Version history: v2.0.1 | 2026-03-31T11:41:43.013Z | auto **Changelog for version 2.0.1:** - Updated installation instructions: now only supports git-based install; ClawHub install inst

62
Rank
84
Safety
1.2k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.2K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s179k4whbg6nemkay67hmbbhf983z42b:complex-task-subagent
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-miyan1221-complex-task-subagent/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

142,217 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: complex-task-subagent
description: Complex task orchestration and subagent command framework. Execute multi-stage complex tasks via subagent (sessions_spawn), including task breakdown, state management, checkpoint-driven, timeout retry, auto-progress and sync. Suitable for serial task orchestration scenarios requiring reliable execution, auto-recovery and unattended operation.
---

# 复杂任务指挥子代理(Complex Task Subagent)

## 安装

### 当前安装方式(推荐)

**暂不支持 clawhub 安装,后续公开上架后可使用下发指令安装。**

**当前使用 git 安装且无需重启即可生效。**

```bash
# 克隆仓库
git clone https://gitee.com/GoSundayPlus/complex-task-subagent-skill.git ~/.openclaw/workspace/skills/complex-task-subagent
```

**更新方法:**

```bash
cd ~/.openclaw/workspace/skills/complex-task-subagent
git pull
```

⚠️ **注意:** 无需重启 OpenClaw Gateway,技能修改后自动生效。

## 快速开始

**适用场景**:当你需要通过子代理执行多阶段复杂任务时使用此技能。

**触发条件**:当用户提到以下关键词时,本技能会被自动激活:
- "深度工作模式"
- "深夜工作模式"
- "深夜无人模式"
- "deepwork模式"
- "无人值守"
- "自动推进"
- "任务编排"
- "子代理"

**核心价值**:
- 可靠的任务编排和状态管理
- 自动检测和推进已完成的阶段
- 超时和重试机制,提高鲁棒性
- 检查点驱动,支持任务恢复
- 集成 OpenClaw Heartbeat 实现无人值守
- 🌙 **夜间无人模式**:提前收集必要信息,在用户休息时自助决策完成任务
- 🔑 **关键节点确认模式**:重要决策点自动提醒用户,超时自动切换无人模式
- 💾 **智能缓存管理**:子代理临时缓存,正常完成自动回收,异常中断可恢复
- ⚡ **深度工作模式**:完全无人值守的自动化任务执行框架

## Cron 任务调用方法参考

想让定时任务发送消息到聊天窗口,必须先获取目标 ID(可以从终端获取)。

### 基本参数说明

| 参数 | 说明 | 必需 |
|------|------|------|
| `--name` | 任务名称 | ✅ |
| `--cron` | Cron 表达式(标准 5 字段格式) | ✅ |
| `--session` | 会话类型(isolated) | ✅ |
| `--message` | 要发送的消息内容或任务描述 | ✅ |
| `--agent` | 指定子代理(可选,默认使用主 agent) | ⚠️ |
| `--tz` | 时区(推荐:Asia/Shanghai) | ⚠️ |
| `--announce` | 开启消息投递 | ✅ |
| `--channel` | 指定渠道 | ✅ |
| `--to` | 指定目标(用户/群组/话题 ID) | ✅ |
| `--best-effort-deliver` | 失败不影响任务(推荐) | ⚠️ |

### Cron 表达式周期规则

**重要说明:**

1. **不支持相对时间**:❌ `"now + 10m"`、`"in 5 minutes"` 等
2. **标准格式要求**:✅ 必须是 5 个空格分隔的字段:`分 时 日 月 周`
3. **周期性执行**:❌ 不支持一次性执行,只能周期性执行
4. **时区设置**:⚠️ 默认使用 UTC,建议添加 `--tz "Asia/Shanghai"` 使用北京时间

### Cron 表达式示例

```bash
# 每 5 分钟
"*/5 * * * *"

# 每 10 分钟
"*/10 * * * *"

# 每 30 分钟
"*/30 * * * *"

# 每小时(整点)
"0 * * * *"

# 每天早上 9 点
"0 9 * * *"

# 每天晚上 10 点
"0 22 * * *"

# 每周一早上 9 点
"0 9 * * 1"

# 每月 1 日早上 9 点
"0 9 1 * *"
```

### 获取目标 ID 的方法

**从终端获取:**

1. **当前会话信息**:查看终端输出的 inbound_meta,找到 chat_id
2. **飞书群组 ID**:从飞书群 URL 中提取
3. **用户 ID**:从飞书设置中查看

**示例:**
```bash
# 当前飞书群聊 ID
chat_id: "oc_2495bf92d31c385fc9818642325fb3d0"

# 用户 ID
user_id: "ou_f2aa56becf853be2f515f64e1904d760"
```

### 完整示例(单行指令)

**重要:所有指令必须在一行完成,换行符会导致解析错误。**

```bash
# 每日 9 点提醒(北京时间)
openclaw cron add --name "每日提醒" --cron "0 9 * * *" --session isolated --message "早上好!今日任务..." --announce --channel feishu --to "7808697964" --tz "Asia/Shanghai" --best-effort-deliver

# 每 5 分钟测试
openclaw cron add --name "快速测试" --cron "*/5 * * * *" --session isolated --message "🧪 cron功能测试成功!" --announce --channel feishu --to "oc_2495bf92d31c385fc9818642325fb3d0" --tz "Asia/Shanghai" --best-effort-deliver

# 每小时查询天气(指定子代理)
openclaw cron add --name "天气查询" --cron "0 * * * *" --session isolated --agent "weather_agent" --message "查询当前天气和时间

_meta.json

{
  "ownerId": "kn77yxarhpayy11pgx35jvt1p582z24m",
  "slug": "complex-task-subagent",
  "version": "2.0.1",
  "publishedAt": 1774957303013
}

references/advanced-patterns.md

# 高级模式

> 复杂任务指挥子代理的高级使用模式和最佳实践

---

## 📚 目录

- [并行任务执行](#并行任务执行)
- [条件分支](#条件分支)
- [动态阶段生成](#动态阶段生成)
- [任务链和依赖](#任务链和依赖)
- [错误恢复策略](#错误恢复策略)
- [监控和可视化](#监控和可视化)
- [性能优化](#性能优化)

---

## 并行任务执行

### 场景

当多个任务可以同时执行且无依赖关系时,使用并行模式。

### 实现方式

```json
{
  "taskId": "parallel-task-20260312",
  "executionMode": "parallel",
  "phases": {
    "phase1": {
      "name": "审核文档 A",
      "status": "pending",
      "dependencies": [],
      "parallelGroup": 1
    },
    "phase2": {
      "name": "审核文档 B",
      "status": "pending",
      "dependencies": [],
      "parallelGroup": 1
    },
    "phase3": {
      "name": "审核文档 C",
      "status": "pending",
      "dependencies": [],
      "parallelGroup": 1
    },
    "phase4": {
      "name": "合并审核结果",
      "status": "pending",
      "dependencies": ["phase1", "phase2", "phase3"],
      "parallelGroup": 2
    }
  }
}
```

### 启动逻辑

```python
def start_parallel_phases(task_progress):
    """启动并行阶段的子代理"""

    # 找到所有可以启动的阶段
    ready_phases = []
    for phase_id, phase in task_progress["phases"].items():
        if phase["status"] == "pending":
            # 检查依赖
            deps_satisfied = True
            for dep in phase.get("dependencies", []):
                if task_progress["phases"][dep]["status"] != "completed":
                    deps_satisfied = False
                    break

            if deps_satisfied:
                ready_phases.append(phase_id)

    # 按并行分组
    groups = {}
    for phase_id in ready_phases:
        group = task_progress["phases"][phase_id].get("parallelGroup", 1)
        if group not in groups:
            groups[group] = []
        groups[group].append(phase_id)

    # 启动每个组
    for group_id, phase_ids in groups.items():
        print(f"启动并行组 {group_id}: {phase_ids}")
        for phase_id in phase_ids:
            phase = task_progress["phases"][phase_id]
            start_subagent(phase_id, phase)
```

### 注意事项

- ⚠️ 确保并行任务之间没有资源冲突
- ⚠️ 监控子代理数量,避免过多并发
- ✅ 合理设置超时时间
- ✅ 记录并行任务的启动和完成顺序

---

## 条件分支

### 场景

根据前一个阶段的结果,决定执行哪个后续阶段。

### 实现方式

```json
{
  "taskId": "conditional-task-20260312",
  "phases": {
    "phase1": {
      "name": "审核代码",
      "status": "pending",
      "branches": {
        "no_issues": {
          "nextPhase": "phase2",
          "condition": "result.issues.length == 0"
        },
        "has_issues": {
          "nextPhase": "phase3",
          "condition": "result.issues.length > 0"
        }
      }
    },
    "phase2": {
      "name": "直接部署",
      "status": "pending",
      "dependencies": ["phase1"]
    },
    "phase3": {
      "name": "修复问题",
      "status": "pending",
      "dependencies": ["phase1"]
    }
  }
}
```

### 条件评估逻辑

```python
def evaluate_conditional_branch(task_progress, phase_id, checkpoint):
    """评估条件分支"""

    phase = task_progress["phases"][phase_id]
    branches = phase.get("branches", {})

    # 读取检查点
    import json
    with open(checkpoint, 'r') as f:
        checkpoint_data = json.load(f)

    # 评估每个分支
    for branc

references/quick-start.md

# 快速开始示例

> 一个完整的 4 阶段任务示例,展示如何使用复杂任务指挥子代理技能

---

## 任务概述

**任务**:创建 OpenClaw Skills 封装方法文档和技能

**阶段划分**:
1. 阶段 1:研究 OpenClaw Skills 封装方法
2. 阶段 2:创建技能目录结构
3. 阶段 3:编写 SKILL.md 和参考文档
4. 阶段 4:打包并上传到 Gitee

---

## 步骤 1:初始化任务

### 1.1 创建 task-progress.json

```json
{
  "taskId": "openclaw-skills-research-20260312",
  "taskName": "OpenClaw Skills 封装方法研究和技能创建",
  "status": "in_progress",
  "currentPhase": 1,
  "completedPhases": 0,
  "totalPhases": 4,
  "lastUpdated": "2026-03-12T02:00:00Z",
  "checkpointsDir": "/root/.openclaw/workspace/complex-task-subagent-experience/checkpoints",
  "phases": {
    "phase1": {
      "name": "研究 OpenClaw Skills 封装方法",
      "status": "pending",
      "timeout": 1800000,
      "maxRetries": 3,
      "retries": 0,
      "checkpoint": "phase1-research.json",
      "output": "/root/.openclaw/workspace/research/skills-development/OPENCLAW_SKILLS_封装方法.md"
    },
    "phase2": {
      "name": "创建技能目录结构",
      "status": "pending",
      "timeout": 600000,
      "maxRetries": 3,
      "retries": 0,
      "checkpoint": "phase2-structure.json",
      "output": "/root/.openclaw/workspace/skills/complex-task-subagent/"
    },
    "phase3": {
      "name": "编写 SKILL.md 和参考文档",
      "status": "pending",
      "timeout": 3600000,
      "maxRetries": 3,
      "retries": 0,
      "checkpoint": "phase3-docs.json",
      "output": "/root/.openclaw/workspace/skills/complex-task-subagent/SKILL.md"
    },
    "phase4": {
      "name": "打包并上传到 Gitee",
      "status": "pending",
      "timeout": 300000,
      "maxRetries": 3,
      "retries": 0,
      "checkpoint": "phase4-gitee.json",
      "output": "/root/.openclaw/workspace/skills/complex-task-subagent.skill"
    }
  }
}
```

### 1.2 创建 checkpoints 目录

```bash
mkdir -p /root/.openclaw/workspace/complex-task-subagent-experience/checkpoints
```

### 1.3 配置 Heartbeat

编辑 `HEARTBEAT-TASK.md`(见主 SKILL.md 文档)。

---

## 步骤 2:启动阶段 1

### 2.1 启动子代理

```bash
sessions_spawn \
  --task "研究 OpenClaw Skills 的封装方法,包括:1. 阅读 Skill Creator 的 SKILL.md;2. 学习技能目录结构和打包流程;3. 整理封装方法并输出到 /root/.openclaw/workspace/research/skills-development/OPENCLAW_SKILLS_封装方法.md;4. 完成后写入检查点 /root/.openclaw/workspace/complex-task-subagent-experience/checkpoints/phase1-research.json" \
  --label "subagent-research" \
  --runtime "subagent" \
  --mode "run" \
  --timeoutSeconds 1800 \
  --cwd "/root/.openclaw/workspace"
```

### 2.2 子代理完成任务后

子代理应该:

1. 读取相关文档
2. 创建研究报告
3. 写入检查点:

```json
{
  "checkpointId": "phase1-research",
  "phase": "phase1",
  "phaseName": "研究 OpenClaw Skills 封装方法",
  "status": "completed",
  "completedAt": "2026-03-12T02:30:00Z",
  "subagent": "subagent-research",
  "output": "/root/.openclaw/workspace/research/skills-development/OPENCLAW_SKILLS_封装方法.md",
  "result": {
    "success": true,
    "message": "研究完成"
  }
}
```

### 2.3 Heartbeat 检测并推进

Heartbeat 检测到检查点后:

1. 更新 task-progress.json:

```json
{
  "phase1": {
    "status": "completed",
    "completedAt": "2026-03-12T02:30:00Z",
    "subagent": "s

references/troubleshooting.md

# 故障排查

> 复杂任务指挥子代理的常见问题和解决方案

---

## 📚 目录

- [子代理问题](#子代理问题)
- [检查点问题](#检查点问题)
- [Heartbeat 问题](#heartbeat-问题)
- [状态文件问题](#状态文件问题)
- [Gitee 同步问题](#gitee-同步问题)
- [性能问题](#性能问题)
- [调试技巧](#调试技巧)

---

## 子代理问题

### 问题 1:子代理无法启动

**症状**:
```
Error: Failed to spawn subagent
```

**可能原因**:
1. OpenClaw Gateway 未运行
2. 子代理服务未配置
3. 网络问题
4. 资源不足

**排查步骤**:

1. 检查 Gateway 状态:
   ```bash
   openclaw gateway status
   ```

2. 检查子代理列表:
   ```bash
   subagents list
   ```

3. 检查日志:
   ```bash
   openclaw gateway logs --tail 100
   ```

4. 检查系统资源:
   ```bash
   free -h
   df -h
   ```

**解决方案**:

1. 启动 Gateway:
   ```bash
   openclaw gateway start
   ```

2. 检查网络连接:
   ```bash
   ping google.com
   ```

3. 增加超时时间:
   ```json
   {
     "timeout": 3600000  // 1 小时
   }
   ```

---

### 问题 2:子代理超时

**症状**:
- 阶段状态一直是 "running"
- 超时时间已过
- 日志显示超时错误

**可能原因**:
1. 任务过于复杂
2. 子代理卡死
3. 网络问题
4. API 限流

**排查步骤**:

1. 检查阶段状态:
   ```bash
   cat /root/.openclaw/workspace/task-progress.json | grep -A 10 "phase3"
   ```

2. 检查子代理日志:
   ```bash
   subagents list
   # 找到对应的 subagent ID
   # 查看详细日志
   ```

3. 检查网络连接:
   ```bash
   curl -I https://api.example.com
   ```

**解决方案**:

1. 增加超时时间:
   ```json
   {
     "timeout": 7200000  // 2 小时
   }
   ```

2. 重新启动子代理:
   ```bash
   # 手动重试
   sessions_spawn --task "..." --label "subagent-name" ...
   ```

3. 分解任务:
   - 将大任务拆分为多个小任务
   - 每个小任务独立执行

---

### 问题 3:子代理崩溃

**症状**:
- 子代理状态变为 "failed"
- 日志显示异常错误
- 检查点文件未创建

**可能原因**:
1. 代码错误
2. 资源不足
3. 依赖问题
4. 权限问题

**排查步骤**:

1. 查看崩溃日志:
   ```bash
   openclaw gateway logs --tail 200 | grep -i error
   ```

2. 检查检查点目录:
   ```bash
   ls -la /root/.openclaw/workspace/complex-task-subagent-experience/checkpoints/
   ```

3. 检查权限:
   ```bash
   ls -la /root/.openclaw/workspace/
   ```

**解决方案**:

1. 修复代码错误:
   - 查看详细错误信息
   - 修复代码后重试

2. 增加资源限制:
   ```bash
   # 增加 Node.js 内存限制
   export NODE_OPTIONS="--max-old-space-size=4096"
   ```

3. 修复权限:
   ```bash
   chmod -R 755 /root/.openclaw/workspace/
   ```

---

### 问题 4:子代理结果错误

**症状**:
- 子代理完成但结果不正确
- 输出文件格式错误
- 数据不完整

**可能原因**:
1. 任务描述不清晰
2. 子代理理解错误
3. 数据质量问题

**排查步骤**:

1. 检查输出文件:
   ```bash
   cat /root/.openclaw/workspace/output/result.md
   ```

2. 检查检查点:
   ```bash
   cat /root/.openclaw/workspace/complex-task-subagent-experience/checkpoints/phaseX.json
   ```

3. 验证任务描述:
   - 是否足够具体?
   - 是否有歧义?

**解决方案**:

1. 改进任务描述:
   - 更具体,避免模糊表述
   - 提供示例
   - 明确输出格式

2. 增加验证步骤:
   - 子代理完成前自我验证
   - 主会话验证结果

3. 使用参考文档:
   - 提供 examples/
   - 提供模板

---

## 检查点问题

### 问题 1:检查点文件未创建

**症状**:
- 子代理显示完成
- 但 checkpoints/ 目录为空
- Heartbeat 无法推进下一阶段

**可能原因**:
1. 子代理忘记写入检查点
2. 检查点路径错误
3. 权限问题

**排查步骤**:

1. 检查 checkpoints 目录:
   ```bash
   ls -la /root/.openclaw/workspace/complex-task-subagent-experience/checkpoints/
   ```

2. 检查权限:
   ```bash
   ls -ld /root/.openclaw/workspace/complex-task-subagent-experience/
   ```

3. 检查子代理日志:
   ```bash
   openclaw gateway logs --tail 100
   ```

**解决方案**:

1. 在任务描述中明确要求写入检查点:
   ```
   "完成后必须写入检查点文件到
    /root/.openclaw/

Sponsored

Ads related to Complex Task Subagent and adjacent AI workflows.