auto-resume-tasks

Event-driven task self-recovery. When notified of background task failures or interruptions, intelligently determines recovery strategy based on error types and action/transaction attributes; uses full-jitter backoff to avoid thundering, semantic hashing to prevent loops, with the goal of minimizing token waste.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "auto-resume-tasks" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-939ee468abfd51e4102bbf5ef25c66790db0d9f95e470e8e3f12430f18fc2372. Verify the upstream source and version against https://skillhub.cn/skills/user_976799b2/auto-resume-tasks before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Event-driven task self-recovery. When notified of background task failures or interruptions, intelligently determines recovery strategy based on error types and action/transaction attributes; uses full-jitter backoff to avoid thundering, semantic hashing to prevent loops, with the goal of minimizing token waste.

0 Downloads

Introduction source: third_party · user_976799b2 · 1.0.1 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: auto-resume-tasks
description: 事件驱动的任务自恢复。收到后台任务失败/中断通知时,基于错误类型和动作事务属性智能判断恢复策略,全抖动退避防惊群,语义哈希防死循环,最小化token浪费。
triggers:
  - 收到 `<hana-background-result>` 或任务失败回调
  - 子代理/工作流/媒体生成任务状态异常
  - 任务长时间无响应
default-enabled: false

Auto-Resume on Failure V2.1

Activation & Contract(调用约定)

本 Skill 是被动响应型:不主动轮询,只在宿主 Agent 收到后台任务异常信号时被调用。

1. 启用方式

  • manifest 中 default-enabled: false 时,宿主 Agent 需在其后台任务处理钩子里显式调用本 Skill。
  • 推荐触发时机:宿主收到 <hana-background-result> 消息,或自身 check_pending_tasks 返回 failed 状态的任务时。

2. 平台信号格式(真实字段)

后台任务异常通过 <hana-background-result> 送达,宿主应从中解析以下字段并传入本 Skill:

<hana-background-result>
  任务类型:subagent | workflow | media
  任务ID:threadId 或 taskId(平台提供)
  状态:failed | timeout | interrupted
  错误摘要:原始错误信息字符串(用于语义指纹)
  已执行阶段:Init | Processing | Finalizing(若平台未提供则按默认推断)
</hana-background-result>

若信号中缺失阶段或事务属性,按本文「事务属性推断」规则补全,并在恢复摘要中显式标注。

3. 最小触发模板(宿主 Agent 调用本 Skill 时使用的 prompt)

收到后台任务异常,请按 auto-resume-tasks 规范处理:
任务类型={type} 任务ID={id} 状态={status} 错误={error_summary} 阶段={phase}
先判断错误分类与事务属性,再决定重试/放弃/转人工,并输出【恢复摘要】。

4. 平台工具映射(恢复动作的实际出口)

任务类型 重试/续跑工具 备注
subagent subagent_reply(threadId, 纠错/续跑指令) 逻辑错误需附纠错 prompt
workflow workflow(resumeFromRunId=taskId) 平台不支持时通知用户
media 重新提交生成请求(含原始参数) 可逆,可覆盖重提交
状态查询 check_pending_tasks 仅在信号不足以判断时调用

中文术语对照表

英文术语 中文含义 说明
subagent 子代理 派生的对话式子智能体任务
workflow 工作流 确定性编排脚本(agent 节点编排)
media 媒体生成 图片/视频生成任务
transient error 瞬态错误 临时故障,值得重试
fatal error 致命错误 参数/权限/资源问题,立即放弃
logical error 逻辑错误 死循环/幻觉/格式错,有限重试
full jitter backoff 全抖动退避 随机化重试窗口防惊群
semantic hash 语义哈希 用语义相似度判重,防死循环
transaction attribute 事务属性 动作副作用等级(只读/可逆/可补偿/最终)
circuit break 熔断 同类错误超阈值后停止重试

Reverse Patterns & FAQ(反模式与避坑)

常见反模式(禁止):

  • ❌ 对最终动作(付款/部署/删库)做自动重试
  • ❌ 仅按进度百分比判断是否恢复(应基于错误类型)
  • ❌ 语义相似度低于 90% 就误熔断(会漏掉真实新错误)
  • ❌ media 重提交前不清理上一次失败产物(造成脏数据/重复计费)
  • ❌ 静默吞掉致命错误(必须升级通知)

FAQ:

  • Q:语义相似度怎么算?没 embedding 怎么办? A:优先用平台 embedding 计算余弦相似度;无 embedding 时降级为「错误类型 + 关键词集合 Jaccard 相似度」近似,阈值可放宽至 0.8 并显式标注为 fallback。
  • Q:阶段信号平台不给我怎么办? A:默认按 Processing 处理;若错误发生在 Init 前(根本没启动)按 Init,若已输出接近完成按 Finalizing。推断结果必须在摘要标注。
  • Q:重试次数用完了还失败呢? A:标记 human_pending 并输出升级通知;后续同任务回调静默丢弃,不再消耗资源。
  • Q:多个任务同时失败会惊群吗? A:不会。全抖动退避使每次重试时间在 [0, t_base*2^n] 内均匀随机,天然打散。

Core Principles

  • 错误归因优先:不按进度百分比判断,而按错误类型决定是否重试
  • 动作事务属性优先:恢复前先判断动作副作用等级,最终动作绝不自动重试
  • 语义哈希防循环:用语义相似度(余弦 > 90%)判断是否陷入同类错误,而非字面量哈希
  • 全抖动退避:随机化重试时间窗口,防止惊群效应
  • 静默优先:能自己解决的不打扰用户,只有需要人工决策时才通知
  • 成本感知:避免对 doomed task 浪费资源

Error Classification

瞬态错误(值得重试)

  • 网络超时、连接失败
  • 429 Rate Limit / 503 Service Unavailable
  • 模型服务暂时不可用
  • 策略:全抖动退避重试,最多 3 次

致命错误(立即放弃)

  • 400 Bad Request / 参数校验失败
  • 401/403 权限不足 / Token 过期
  • 404 资源不存在
  • 策略:直接标记为不可恢复,通知用户

逻辑/内容错误(有限重试)

  • 子代理陷入死循环 / 幻觉 / 输出格式错误
  • 工作流节点逻辑异常
  • 策略:最多重试 1 次,附加纠错 prompt;仍失败则转人工

Action Transaction Classification

恢复任何任务前,先判断该动作的事务属性,优先级高于阶段-错误矩阵:

属性 定义 恢复策略
只读 (Read-only) 查询/检索,不改变外部状态 可放心重试,适用全部退避策略
可逆 (Reversible) 改变状态但有确定性的撤销操作(如创建草稿后删除) 重试前先调用撤销 API 清理残局
可补偿 (Compensatable) 改变外部状态且无法物理撤销(如发送邮件) 重试前先触发补偿工作流(如发送勘误通知)
最终动作 (Final/Irreversible) 不可逆转的关键操作(如付款、删库、部署) 任何错误都绝不重试,直接转人工审核

Workflow

1. 解析通知

从回调消息中提取:

  • 任务类型(subagent / workflow / media)
  • 任务标识(threadId / taskId)
  • 错误类型(瞬态 / 致命 / 逻辑)
  • 错误摘要(用于语义相似度计算)
  • 已执行阶段(Init / Processing / Finalizing)
  • 动作事务属性(如可推断)

仅在通知信息不足以判断时,才调用 check_pending_tasks。

事务属性推断(缺失时)

如果通知中未显式提供事务属性,按以下默认规则推断:

  • media 任务 → 默认 可逆 (Reversible),因生成结果通常可重新提交覆盖
  • subagent 任务 → 默认 只读 (Read-only),除非对话 prompt 中出现 发送、提交、部署、付款、删除 等最终动作关键词,则升级为 最终动作
  • workflow 任务 → 默认 只读 (Read-only),若涉及多阶段副作用(如写入文件、发送通知)再升级为 可逆 或 可补偿 推断结果必须在恢复摘要中显式标注,供后续审计。

2. 幂等检查

  • 检查当前会话中该任务ID是否已恢复过
  • 计算错误语义指纹:基于错误类型 + 错误摘要的语义相似度
  • 若与历史错误语义相似度 > 90% → 熔断,不再重试,直接通知

3. 事务属性优先判断

  • 最终动作:任何错误 → 直接转人工,不进入重试流程
  • 只读动作:进入错误分类-阶段联合判断
  • 可逆动作:重试前先执行撤销,再进入重试流程
  • 可补偿动作:重试前先触发补偿,再进入重试流程

4. 阶段-错误联合判断(仅对非最终动作)

阶段 瞬态错误 致命错误 逻辑错误
Init 全抖动退避,最多 3 次 立即放弃 重试 1 次
Processing 全抖动退避,最多 3 次 立即放弃 重试 1 次
Finalizing 全抖动退避,最多 2 次 立即放弃 重试 1 次

5. 全抖动退避公式

t_calculated = min(t_max, t_base * 2^attempt_count)
t_retry = Random(0, t_calculated)
  • t_base = 5s, t_max = 60s
  • 每次重试时间在 [0, 当前最大退避时间] 内均匀随机分布
  • 多任务并发时自动打散,避免惊群

6. 恢复动作

  • subagent:subagent_reply(threadId, 纠错/续跑指令)
    • 瞬态错误:简单重试指令
    • 逻辑错误:附加失败日志摘要 + 纠错 prompt
    • 上下文压缩:若历史对话较长,先提取关键摘要再注入
  • workflow:如支持则 workflow(resumeFromRunId=taskId),否则通知用户平台限制
  • media:重新提交生成请求,附原始参数

6.5 恢复日志输出

每次恢复尝试后,立即向会话上下文输出结构化摘要:

【恢复摘要】
任务类型:{type}
任务ID:{id}
错误类型:{error_type}
事务属性:{transaction_type}
阶段:{phase}
重试次数:{retry_count}
恢复动作:{action}
结果:{resumed | failed | human_pending}

该摘要仅供当前会话复盘使用,不做持久化存储。

7. 升级通知(仅必要时)

触发条件:

  • 达到重试上限
  • 致命错误
  • 语义相似度 > 90% 的同类错误重复出现
  • 任务涉及最终动作
  • 累积 token 消耗超过阈值(估算)

通知格式:

【任务中断需人工处理】
任务:{type} / {id}
原因:{error_type} - {reason}
动作属性:{transaction_type}
阶段:{phase}
已自动恢复:{retry_count} 次
建议:{suggestion}

8. 状态标记

恢复尝试后,在会话状态中记录:

  • 任务 ID
  • 错误语义指纹(相似度向量)
  • 重试次数
  • 最后重试时间
  • 事务属性
  • 状态(resumed / human_pending / failed)

标记为 human_pending 后,后续同一任务的回调直接静默丢弃。

Evals

最小验证集,覆盖核心决策链路:

ID 场景 错误类型 事务属性 预期决策
E01 网络超时 瞬态 只读 全抖动退避,最多 3 次后恢复或转人工
E02 429 Rate Limit 瞬态 可逆 先执行撤销,再全抖动退避重试
E03 401 Token 过期 致命 只读 直接标记不可恢复,通知用户
E04 子代理输出格式错误 逻辑 只读 重试 1 次并附加纠错 prompt
E05 同类错误重复出现 逻辑 可逆 语义相似度 > 90% → 熔断,不再重试
E06 付款操作失败 致命 最终动作 绝不重试,直接转人工审核

执行方式:人工走查或脚本注入模拟错误通知,验证上述决策是否正确。

待补充: 真实平台的 check_pending_tasks 返回格式样例,用于提升推断准确率。

Retry Policy

  • 瞬态错误:最多 3 次,全抖动退避
  • 逻辑错误:最多 1 次
  • 致命错误:0 次
  • 最终动作:0 次,直接转人工
  • 语义相似度 > 90% 的同类错误 → 直接熔断
  • 标记为 human_pending 后,不再自动处理

Current listing version

1.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value92/100

Highlights

  • 针对后台任务失败/中断提供智能恢复策略,解决高频刚需场景
  • 完整闭环:错误分类、事务属性判断、退避策略、语义哈希防循环
  • 显著提升自动化任务稳定性,减少人工干预成本
Trigger Precision95/100

Highlights

  • 触发词精准覆盖多种异常信号(hana-background-result、任务失败回调等)
  • description 位置正确且内容完整,无截断或错位
Structure and Standards93/100

Highlights

  • Phase/步骤划分清晰,逻辑严谨(8步核心流程)
  • 提供端到端验证集(Evals 表格)覆盖核心决策链路
  • frontmatter 完整,术语对照表提升可读性
Execution Reliability94/100

Highlights

  • 工具映射明确,参数正确(subagent_reply、workflow resume 等)
  • 覆盖主要异常类型并制定差异化策略
  • 最终动作绝不自动重试,具备熔断与升级机制
Evidence Verifiability (mean of the first four)94/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.