AgentSkillsCN

cleanup-stale-executions

从 skill_execution.json 中清理过期的技能执行记录。将运行时间超过 30 分钟或处于非活跃状态超过 10 分钟的执行标记为失败,并移除已完成且超过 5 分钟的执行记录。可定期通过 Cron 任务运行。适用于用户输入“清理执行记录”或“清理过期技能”时使用。

SKILL.md
--- frontmatter
name: cleanup-stale-executions
description: Clean up stale skill executions from skill_execution.json. Marks running >30min or inactive >10min as failed, removes completed >5min old. Run periodically via cron. Use when user says "cleanup executions" or "stale skill cleanup".

Cleanup Stale Executions

Maintenance skill for ~/.config/aa-workflow/skill_execution.json.

Inputs

None.

Workflow

1. Load Execution File

  • Read ~/.config/aa-workflow/skill_execution.json
  • If missing: return "No execution file found"

2. Process Executions

  • Stale running: status=running, elapsed >30min OR (elapsed >10min AND last event >10min ago) → mark as failed, add stale event
  • Old completed: status in (success, failed), endTime >5min ago → remove from file
  • Idle placeholders: keys with "None" or status=idle → remove

3. Save

  • Update lastUpdated, write back to file

4. Log

  • memory_session_log("Stale execution cleanup", "Cleaned X, marked Y stale, Z remaining")

Output

Summary: stale_marked, cleaned, remaining.