Xpersona
L

Long Task Handler

CLAWHUB · Unverified

自动识别并后台执行预计超30秒的长任务,定期推送进度反馈,避免阻塞和任务堆积,支持超时及完成通知管理。 Skill: Long Task Handler Owner: frankieway Summary: 自动识别并后台执行预计超30秒的长任务,定期推送进度反馈,避免阻塞和任务堆积,支持超时及完成通知管理。 Tags: latest:1.0.0 Version history: v1.0.0 | 2026-03-31T09:52:56.702Z | user Initial release - 长任务处理机制,后台执行,进度反馈,完成通知 Archive index: Archive v1.0.0: 5 files, 8768 bytes Files: _meta.json (136b), package.json (483b), skill-card.md (2340b), SKILL.md (10052b), task-manager.js (5631b) File v1.0.0:SKILL.md Long Task Han

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K 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 s17ed490z7a9smvan099pss95h83hv41:long-task-handler
  1. Node.js workspace detected. Install dependencies securely: run `npm ci --ignore-scripts` to prevent post-install lifecycle triggers from running arbitrary code, then selectively audit the dependency tree.
  2. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  3. 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-frankieway-long-task-handler/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

10,433 characters of source documentation, loaded on request.

Extracted files

4 files captured from the source.

SKILL.md

# Long Task Handler - 长任务处理技能

## 触发条件

当用户任务符合以下特征时激活此技能:

1. **预计耗时 > 30 秒** 的任务(编译、部署、大数据处理、模型训练等)
2. **需要进度反馈** 的任务(用户需要知道进展)
3. **可能阻塞队列** 的任务(会影响其他用户请求)
4. 用户明确要求"后台运行"、"别阻塞"、"慢慢跑"等

触发关键词:
- "长任务"、"耗时"、"后台运行"、"别等我"
- "跑完告诉我"、"有进展通知我"
- 编译、部署、训练、处理大量数据等场景

## 核心机制

### 1. 任务分流架构

```
用户请求 → 立即确认 → 后台 exec → 定期轮询 → 进展推送 → 完成通知
            ↓           ↓          ↓          ↓          ↓
         (1 秒内)   (不阻塞)   (30 秒间隔)  (实时)    (自动)
```

### 2. 三层处理策略

| 任务类型 | 处理方式 | 工具 |
|----------|----------|------|
| 短任务 (<30 秒) | 直接执行 | `exec` 前台 |
| 中长任务 (30 秒 -5 分) | 后台执行 + 定期轮询 | `exec background` + `process poll` |
| 长任务 (>5 分) | 子代理隔离 + 进度推送 | `sessions_spawn` + `message` |

## 执行流程

### Step 1: 任务评估

```javascript
function assessTask(command) {
  // 预估耗时因素
  const longTaskIndicators = [
    /compile|build|deploy/i,
    /train|fine-tune/i,
    /process.*data|migration/i,
    /export|backup.*large/i,
    /\b(ffmpeg|docker|webpack|tsc)\b/,
    /test.*--coverage|--all/i,
  ];
  
  // 检查是否有超时/后台标记
  const hasTimeout = /--timeout|-t\s*\d+/.test(command);
  const isBackground = /&$|nohup|background/.test(command);
  
  // 返回评估结果
  return {
    estimatedDuration: 'short' | 'medium' | 'long',
    shouldBackground: boolean,
    needsProgressReporting: boolean
  };
}
```

### Step 2: 立即确认

**必须**在 5 秒内给用户确认回复:

```
🫡 收到!这个任务预计需要 X 分钟,我会在后台运行。

任务:[任务简述]
预计耗时:X 分钟
通知方式:每 30 秒报告进展,完成后立即通知

你可以继续问我其他问题,不用等这个任务完成~
```

### Step 3: 后台启动

```javascript
const { sessionId } = await exec({
  command: taskCommand,
  background: true,
  yieldMs: 2000,      // 2 秒后切到后台
  timeout: timeoutSeconds || 3600,  // 默认 1 小时超时
  workdir: workspaceDir
});
```

### Step 4: 进度监控循环

```javascript
const monitorProgress = async (sessionId, options = {}) => {
  const {
    pollIntervalMs = 30000,  // 30 秒轮询
    reportNoChange = false,   // 无变化是否报告
    maxSilentMinutes = 5      // 最大静默时间
  } = options;
  
  let lastOutput = '';
  let silentSince = Date.now();
  
  const interval = setInterval(async () => {
    const result = await process({
      action: 'poll',
      sessionId
    });
    
    // 检查是否有新输出
    if (result.output && result.output !== lastOutput) {
      const newLines = result.output.slice(lastOutput.length);
      if (newLines.trim()) {
        await message({
          channel: 'feishu',
          message: `📊 任务进展:\n\`\`\`\n${newLines.slice(-500)}\n\`\`\``
        });
        lastOutput = result.output;
        silentSince = Date.now();
      }
    }
    
    // 检查静默超时
    if (Date.now() - silentSince > maxSilentMinutes * 60000) {
      await message({
        message: `⚠️ 任务已静默运行 ${maxSilentMinutes} 分钟,仍在进行中...`
      });
      silentSince = Date.now();  // 重置计时
    }
    
    // 检查是否完成
    if (result.exitCode !== null) {
      clearInterval(interval);
      await notifyCompletion(sessionId, result);
    }
  }, pollIntervalMs);
  
  return interval;
};
```

### Step 5: 完成通知

```javascript
const notifyCompletion = async (sessionId, result) => {
  const fullLog = await

_meta.json

{
  "ownerId": "kn7eag7808pwjcwsa9mw5hwkr582djk3",
  "slug": "long-task-handler",
  "version": "1.0.0",
  "publishedAt": 1774950776702
}

skill-card.md

## Description:

Long Task Handler helps an agent identify long-running tasks, run them in the background, and report progress, timeout, failure, and completion status without blocking the main conversation.

This skill is ready for commercial/non-commercial use.

## Publisher:

[frankieway](https://clawhub.ai/user/frankieway)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and agent operators use this skill to manage compile, deployment, migration, data processing, and model-training work that is expected to run longer than a normal interactive response. It guides the agent to acknowledge the work quickly, run it in the background, poll for progress, and send concise status or completion updates.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Task progress and completion notifications may expose raw command output, secrets, private paths, or sensitive operational details in chat.

Mitigation: Use the skill only where sending task status to chat is acceptable, avoid commands that print secrets, redact logs, and send summaries by default.

Risk: Task commands and status can be retained in plaintext local state.

Mitigation: Store only minimal task state, restrict file permissions, and clean up or archive task records after they are no longer needed.

Risk: Notifications sent to a broad or incorrect channel can disclose task details to unintended readers.

Mitigation: Route notifications to the originating conversation or an explicitly approved destination.

## Reference(s):

- [ClawHub skill page](https://clawhub.ai/frankieway/skills/long-task-handler)

## Skill Output:

**Output Type(s):** [Text, Markdown, Shell commands, Configuration, Guidance]

**Output Format:** [Markdown with inline shell commands and JSON configuration]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Includes periodic status summaries, completion notices, timeout and failure summaries, and recent log excerpts.]

## Skill Version(s):

1.0.0 (source: server release evidence and artifact metadata)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

package.json

{
  "name": "long-task-handler",
  "version": "1.0.0",
  "description": "长任务处理技能 - 后台执行、进度反馈、不阻塞队列",
  "main": "task-manager.js",
  "scripts": {
    "test": "echo \"No tests specified\""
  },
  "keywords": [
    "openclaw",
    "skill",
    "task",
    "background",
    "queue",
    "long-running",
    "progress"
  ],
  "author": "Frankie 助理",
  "license": "MIT",
  "openclaw": {
    "type": "skill",
    "minVersion": "1.0.0"
  }
}

Sponsored

Ads related to Long Task Handler and adjacent AI workflows.