360 Secure SkillHub
360 安全技能中心

Lite Session Cleaner

该 Skill 通过 openclaw 的会话列表查询接口识别活跃会话,比较各会话最后活动时间与当前时间,对超过 3600 秒无活动的会话先向目标频道发送“当前会话已经结束”消息,再调用终止命令关闭会话,并在每日日志中记录清理动作,适合以定时任务方式周期运行。

artwebs
artwebs
热度 49.32
最近更新 2026-05-11 17:44:55
分类:自动化依赖:代码执行 / MCP 服务应用场景:工作流 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add lite-session-cleaner
Metadata
name
session-cleaner
description
Automatically cleans up inactive sessions (older than 1 hour) and sends a notification.
metadata
{"openclaw":{"requires":{"bins":["openclaw"]}}}

Session Cleaner Skill

This skill is designed to be run via a cron job or periodic task to monitor and prune stale sessions.

Usage

The skill relies on openclaw sessions_list to identify old sessions and openclaw sessions_kill to terminate them. It can be integrated into a TaskFlow or run as a standalone script via exec.

Implementation Logic

  1. Identify: Use sessions_list to retrieve all active sessions.
  2. Filter: Compare the last_activity timestamp of each session with the current time.
  3. Action: For sessions where current_time - last_activity > 3600 seconds:
    • Send a message to the session's target channel (e.g., via message tool) stating: "当前会话已经结束".
    • Execute sessions_kill <session_id>.
  4. Log: Record the cleaning action in the daily log.

Requirements

  • openclaw CLI installed and accessible.
  • Access to session metadata.