← 返回 Skills 市场
ori-claw

Cron Gate

作者 ori-claw · GitHub ↗ · v1.0.0
cross-platform ✓ 安全检测通过
313
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install cron-gate
功能描述
Pre-checks sessions for new messages via a zero-token Python script to trigger expensive OpenClaw crons only when new activity exists, saving tokens.
使用说明 (SKILL.md)

Cron Gate

Stop wasting tokens on crons with nothing to do.

Every OpenClaw cron that spawns an isolated LLM session burns tokens — prompt loading, Weave files, tool calls — even when there's nothing new to process. If you run memory integration across 5 sessions twice a day, that's 10 LLM wake-ups. Most of them find nothing and go back to sleep, having burned ~40K tokens each.

Cron Gate is a zero-token Python gatekeeper that checks for new activity before triggering expensive LLM crons. No new messages? No wake-up. No tokens burned.

How It Works

System crontab (free)          OpenClaw cron (expensive)
        │                              │
   gate.py runs              disabled, waiting
        │                              │
   checks sessions.json       ┌───────┘
        │                     │
   new activity? ─── yes ───► triggers cron via API
        │
       no ──► exits silently (0 tokens)
  1. A lightweight Python script runs on system crontab (zero LLM cost)
  2. It reads sessions.json to check updatedAt timestamps
  3. Compares against its own state file (last time it triggered each session)
  4. Only calls the OpenClaw gateway API to trigger crons for sessions with genuinely new messages
  5. Idle sessions never wake up — they cost nothing until someone talks in them

Install

1. Copy the gate script

cp gate.py /opt/scripts/cron-gate.py
chmod +x /opt/scripts/cron-gate.py

2. Configure your session-to-cron mapping

Edit the SESSION_CRONS dict in gate.py to map your session keys to their integration cron IDs:

SESSION_CRONS = {
    "agent:main:telegram:group:-1234567890": {
        "evening": "your-evening-cron-id-here",
        "morning": "your-morning-cron-id-here",
    },
    "agent:main:discord:channel:9876543210": {
        "evening": "another-cron-id",
        "morning": None,  # skip morning for this session
    },
}

Finding your session keys: Look in ~/.openclaw/agents/main/sessions/sessions.json

Finding your cron IDs: Run /crons in chat or check the OpenClaw dashboard

3. Disable the original crons

For each integration cron you're gating, disable it (but don't delete — the gate script triggers them on-demand):

/cron update \x3Ccron-id> enabled=false

Or ask your agent: "Disable all memory integration crons — they'll be triggered by the gate script now."

4. Add system crontab entries

# Evening integration window (adjust times to match your schedule)
5 6 * * * /usr/bin/python3 /opt/scripts/cron-gate.py evening >> /var/log/cron-gate.log 2>&1

# Morning integration window
5 18 * * * /usr/bin/python3 /opt/scripts/cron-gate.py morning >> /var/log/cron-gate.log 2>&1

Usage

# Dry run — see what would trigger without actually doing it
python3 gate.py --dry-run evening

# Force a specific slot (ignore time-of-day check)
python3 gate.py morning

# Normal operation (auto-detects slot from UTC hour)
python3 gate.py

Time Windows

The script auto-detects which slot to run based on UTC hour:

  • Evening: 4-8 UTC
  • Morning: 16-20 UTC

Override by passing evening or morning as an argument. When run from crontab with an explicit slot argument, the time window check is bypassed.

State File

Activity timestamps are stored in /opt/scripts/cron-gate-state.json (configurable). This is how the gate knows what's "new" — it compares each session's updatedAt against the last time it triggered that cron.

To reset (re-trigger everything on next run):

rm /opt/scripts/cron-gate-state.json

Token Savings

Real-world numbers from the first deployment:

  • Before: 10 integration crons × 2/day = 20 LLM sessions, ~800K tokens/day
  • After: Only sessions with new activity get triggered. Idle sessions = 0 tokens.
  • Typical savings: 60-80% reduction in integration token costs
  • Gate script cost: Zero. It's pure Python, no LLM involved.

Beyond Memory Integration

This pattern works for any cron that might have nothing to do:

  • Email checks — gate behind inbox message count
  • Social platform rounds — gate behind API health check
  • Notification checks — gate behind unread count
  • Any periodic LLM task — if a cheap check can determine "nothing to do," gate it

The principle: check cheap, wake expensive only when needed.

Requirements

  • Python 3.8+
  • OpenClaw with gateway API running on localhost:18789
  • System crontab access (crontab -e)
  • No additional dependencies (stdlib only)
安全使用建议
This implementation appears coherent and low-risk, but review and follow these operational precautions before installing: - Run the provided dry-run (python3 gate.py --dry-run) to verify behavior and cron mappings before enabling triggers. - Ensure your OpenClaw gateway is bound to localhost:18789 as documented; do not point GATEWAY_URL to an external host unless you trust that endpoint (changing it could cause network calls/exfiltration). - The script reads ~/.openclaw/.../sessions.json (may contain session identifiers/metadata) and writes /opt/scripts/cron-gate-state.json; place files in directories with appropriate ownership and least privilege (avoid running as root when not needed). - Copying to /opt/scripts and adding system crontab entries may require sudo; consider using a per-user directory if you lack root or want to reduce privileges. - Double-check SESSION_CRONS mappings and the cron IDs you disable; test thoroughly to avoid missing important periodic tasks. If you want extra assurance, inspect gate.py locally (you have the full source) and keep GATEWAY_URL at the default to limit the script to local-only API calls.
功能分析
Type: OpenClaw Skill Name: cron-gate Version: 1.0.0 The skill bundle provides a Python script (`gate.py`) designed to optimize OpenClaw cron execution by only triggering expensive LLM crons when new activity is detected in a session. The script reads `~/.openclaw/agents/main/sessions/sessions.json` to check `updatedAt` timestamps and makes local HTTP POST requests to `http://127.0.0.1:18789/api/cron/{cron_id}/run` to trigger crons. While these actions involve accessing sensitive local files and making local API calls, they are explicitly required for the skill's stated purpose of token savings and are not used for data exfiltration or unauthorized remote control. The `SKILL.md` instructions guide the user to set up a system cron and disable existing OpenClaw crons, which is consistent with the skill's functionality. There is no evidence of intentional harmful behavior or prompt injection with malicious objectives.
能力评估
Purpose & Capability
Name/description match the implementation. The script reads ~/.openclaw/.../sessions.json, compares timestamps against a local state file, and calls the OpenClaw gateway to trigger cron jobs; these actions are exactly what the SKILL.md describes. No unrelated binaries, env vars, or resources are required.
Instruction Scope
Instructions and code stay within the declared purpose: editing SESSION_CRONS, running the script from system crontab, and disabling the original crons. The script reads sessions.json and writes a state file (configured at /opt/scripts/cron-gate-state.json by default). One operational note: if you change GATEWAY_URL from localhost to an external host, the script would call that endpoint, so keep the default local gateway to avoid unexpected network calls.
Install Mechanism
No install spec or remote downloads; the skill supplies a small Python file you copy to disk. This is low-risk compared with remote installs. The SKILL.md instructs manual placement (cp + chmod) which may require sudo for /opt/scripts; that is an operational concern, not a coherence issue.
Credentials
The skill requests no environment variables or credentials. It legitimately needs read access to the sessions.json file and write access to its state file. Those accesses are proportional to the stated task. The script does not exfiltrate data by default.
Persistence & Privilege
No special platform privileges requested (always=false). The script is intended to be scheduled in system crontab and writes its own state file; this is normal for its function. Note: installing to /opt/scripts and adding system crontab entries may require elevated privileges — follow least-privilege practices when placing and running the script.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install cron-gate
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /cron-gate 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release — zero-token gatekeeper for OpenClaw crons. Checks session activity before triggering expensive LLM crons.
元数据
Slug cron-gate
版本 1.0.0
许可证
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Cron Gate 是什么?

Pre-checks sessions for new messages via a zero-token Python script to trigger expensive OpenClaw crons only when new activity exists, saving tokens. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 313 次。

如何安装 Cron Gate?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install cron-gate」即可一键安装,无需额外配置。

Cron Gate 是免费的吗?

是的,Cron Gate 完全免费(开源免费),可自由下载、安装和使用。

Cron Gate 支持哪些平台?

Cron Gate 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Cron Gate?

由 ori-claw(@ori-claw)开发并维护,当前版本 v1.0.0。

💬 留言讨论