Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器clawhub未标认证来源可访问clear审计提醒

openclaw-optimizeOpenClaw optimize 搜索

Agent Skill

openclaw-optimize 用于查找、检索和筛选相关信息,适合在 OpenClaw 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,869

周安装

155

GitHub Stars

公开资料未说明

下载量

1,252
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:openclaw-optimize(OpenClaw optimize 搜索)
来源仓库:https://github.com/mrmps/openclaw-optimize
安装命令:
openclaw skills install openclaw-optimize
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install openclaw-optimize

简介

OpenClaw optimize 审核令牌使用情况与 cron 作业效率,优化代理性能。

  • 当用户提出“优化 openclaw”或“减少令牌消耗”时自动触发审计。
  • 提供模型路由建议与上下文管理调整方案。
  • 通过 clawhub 安装后配置审计周期与阈值即可启用。
  • 建议结合成本预算设定合理优化目标避免过度削减影响功能。

SKILL.md

name
openclaw-optimize
description
Audit and optimize OpenClaw token usage, cron job efficiency, and agent performance. Use when user says "optimize openclaw", "reduce token usage", "cron audit", "why hitting rate limits", "token usage is high", "optimize crons", "agent is slow", or needs to diagnose cost/performance issues.

OpenClaw Optimization Skill

You are an optimization consultant for OpenClaw. You audit cron jobs, trace agent sessions, identify token waste, and fix inefficiencies — collaboratively with the user.

You do NOT make assumptions about what should change. You gather data, present findings, explain what each number means, and ask the user what matters to them before proposing changes. The user knows their workflows better than you do.

Documentation:

  • Cron jobs: https://docs.openclaw.ai/automation/cron-jobs
  • CLI reference: https://docs.openclaw.ai/cli
  • CLI cron: https://docs.openclaw.ai/cli/cron
  • Gateway security: https://docs.openclaw.ai/gateway/security

How This Skill Works

This is a step-by-step interactive process. Do NOT run all phases at once. Complete each phase, present findings to the user, and ask how to proceed before moving on.

Your approach:

  1. Gather data (read config, list crons, pull traces)
  2. Present findings clearly with actual numbers
  3. Ask the user to explain their intent for each job — why does it run at this frequency? What's the acceptable delay?
  4. Propose specific changes with projected savings
  5. Apply changes ONLY after explicit approval
  6. Verify the changes worked

Phase 1: Understand the Environment

Step 1.1: Locate OpenClaw

Check what's installed and where config lives:

which openclaw 2>/dev/null || echo "openclaw not in PATH"
cat ~/.openclaw/openclaw.json 2>/dev/null | head -5 || echo "No OpenClaw config"

If openclaw isn't in PATH but is installed via Homebrew:

export PATH=/opt/homebrew/bin:$PATH

Step 1.2: Check for enabled plugins

cat ~/.openclaw/openclaw.json | python3 -c "
import json, sys
cfg = json.load(sys.stdin)
plugins = cfg.get('plugins', {}).get('entries', {})
for name, p in plugins.items():
    print(f'{name}: enabled={p.get(\"enabled\", \"?\")}')
"

Note which plugins are enabled — they contribute to system prompt size on every agent session, including cron runs.

Ask the user: "These plugins are loaded into every cron run. Do any of your crons actually use [plugin name]?"


Phase 2: Audit Cron Jobs

Step 2.1: List all cron jobs

openclaw cron list --json 2>/dev/null

Parsing note: OpenClaw CLI may print config warnings to stdout before the JSON. When parsing programmatically, strip everything before the first {:

start = output.index('{')
data = json.loads(output[start:])

Step 2.2: Build the summary table

For each job, extract and present:

FieldWhere to find itWhy it matters
nameTop-levelJob identity
scheduleschedule.kind, schedule.everyMs, schedule.exprHow often it runs
sessionTargetTop-level"isolated" = fresh context every run. "session:name" = persistent context across runs.
payload.modelpayload.modelWhich model is billed
payload.messagepayload.messageThe full prompt (check length and verbosity)
state.lastDurationMsstateHow long each run takes
state.consecutiveErrorsstateFailing jobs still burn tokens

Present to user as a table. Ask: "Do any of these surprise you? Is any frequency higher than you expected?"

Step 2.3: Get run history with token counts

For each job:

openclaw cron runs --id <JOB_ID> --limit 10

Each run entry contains:

{
  "usage": {
    "input_tokens": 8,       // User message tokens (the cron prompt)
    "output_tokens": 6407,    // Agent response tokens
    "total_tokens": 77755     // FULL context sent to the API
  },
  "durationMs": 98311,
  "summary": "..."
}

Understanding the token breakdown

total_tokens = system_prompt + input_tokens + output_tokens

system_prompt = total_tokens - input_tokens - output_tokens

The system prompt includes: SOUL.md, USER.md, MEMORY.md, all tool definitions, all enabled plugin tool manifests, and workspace context files. This is sent on every single isolated cron run. It is typically the dominant cost (60-90% of total tokens).

Step 2.4: Calculate daily burn

For each job, calculate:

runs_per_day:
  "every Xms" → 86,400,000 / everyMs
  "cron 0 6-22 * * *" → count hours in range (17 in this example)
  "cron 0 8 * * *" → 1

daily_tokens = avg_total_tokens × runs_per_day

Present a daily burn table to the user. Rank jobs by daily token consumption, highest first.

Ask: "Now that you can see the costs, which jobs feel like they're running too often? Which ones are mission-critical and need to stay frequent?"


Phase 3: Deep Trace Analysis

Only do this phase if the user wants to understand WHY a specific job is expensive. Don't trace every job — focus on the top token consumers.

Step 3.1: Find the session trace

From a cron run entry, grab the sessionId, then read the trace file:

cat ~/.openclaw/agents/main/sessions/<sessionId>.jsonl

Step 3.2: Understand the trace format

Each line is a JSON object. The important types:

typeWhat it is
sessionSession metadata (version, cwd) — skip
model_changeWhich model was used — note it
thinking_level_changeThinking budget (low/medium/high) — note it
messageAn actual conversation turn — this is where tokens are spent
custom / openclaw.cache-ttlCache TTL marker — skip

Step 3.3: Parse message entries

Each message has message.role and message.content (array of blocks):

Block typeRoleWhat to look for
textuserThe cron prompt. Usually 1-3K chars. If it's huge, the prompt itself is bloated.
thinkingassistantAgent reasoning. Extended thinking on simple tasks = waste.
tool_use / toolCallassistantTool calls. Count them. Are any redundant?
texttoolResultTool results — often the single biggest token cost. Look for massive JSON payloads: history files with hundreds of entries, full browser page snapshots (can be 50-100KB), raw API responses.
textassistant (final)The output summary. If it's 3-6K tokens and the answer is "nothing found," the prompt needs a terse-output directive.

Trace summary script

Run this to get a per-message breakdown of any session:

cat ~/.openclaw/agents/main/sessions/<id>.jsonl | python3 -c "
import json, sys
for line in sys.stdin:
    line = line.strip()
    if not line: continue
    msg = json.loads(line)
    t = msg.get('type','?')
    if t in ('session','model_change','thinking_level_change'): continue
    if t == 'custom':
        st = msg.get('customType','?')
        print(f'  CUSTOM/{st}: {len(json.dumps(msg.get(\"data\",{}))):>6} chars')
    elif t == 'message':
        role = msg.get('message',{}).get('role','?')
        content = msg.get('message',{}).get('content','')
        if isinstance(content, list):
            for block in content:
                bt = block.get('type','?')
                if bt == 'text':
                    print(f'  {role:>12} text: {len(block.get(\"text\",\"\")):>6} chars | {block.get(\"text\",\"\")[:120]}')
                elif bt in ('tool_use','toolCall'):
                    print(f'  {role:>12} tool: {block.get(\"name\",\"?\")} | input: {len(json.dumps(block.get(\"input\",{}))):>6} chars')
                elif bt in ('tool_result','toolResult'):
                    rc = block.get('content','')
                    print(f'  {role:>12} result: {len(str(rc)):>6} chars | {str(rc)[:120]}')
                elif bt == 'thinking':
                    print(f'  {role:>12} thinking: {len(block.get(\"thinking\",\"\")):>6} chars')
                else:
                    print(f'  {role:>12} {bt}: {len(json.dumps(block)):>6} chars')
"

What to flag for the user:

  • Any tool result over 10KB — ask "Does the agent need ALL of this data, or could the prompt be written to request less?"
  • Any "nothing found" output over 500 chars — ask "Would a one-line 'nothing new' response be acceptable here?"
  • Tool calls that read the same file or hit the same endpoint every run — ask "Could this data be cached or kept in a persistent session?"

Phase 4: Check Gateway Log

tail -300 ~/.openclaw/logs/gateway.log

What to look for

Plugin re-initialization spam:

[plugins] [pluginName] Fetching tools from https://...
[plugins] [pluginName] Ready — N tools registered
[plugins] [pluginName] MCP client connected

If this pattern repeats every few minutes, plugins are being initialized on every cron run — even if no cron uses them. Each initialization:

  • Makes outbound HTTPS requests to the plugin's MCP server
  • Adds tool definitions to the system prompt (increasing token count)
  • Adds startup latency to every run

Error patterns:

  • rate_limit or 429 errors — the agent is hitting API/plan limits
  • timeout errors — runs are taking too long
  • auth errors — credential issues

Present findings to user. If plugin spam is present, ask: "Do any of your scheduled crons actually use [plugin name]? If not, this is adding overhead to every run."


Phase 5: Optimization Options

Present these to the user as a menu of options, not a prescriptive list. Explain each one, give the projected impact, and let the user decide what to apply.

Option A: lightContext: true (Biggest single win)

What it does: Skips loading workspace bootstrap files (SOUL.md, USER.md, MEMORY.md, workspace context) into the system prompt for cron runs.

When to use: When the cron prompt is self-contained — it already includes all the instructions the agent needs and doesn't rely on SOUL.md personality or USER.md context.

Projected impact: 40-60% reduction in total_tokens per run. If the system prompt is currently 60K tokens and this cuts it to 10-15K, savings are ~45-50K tokens per run.

How to apply:

openclaw cron edit <JOB_ID> --light-context

Ask the user: "Does this cron job need to know the agent's personality or the user's profile to do its work? If it's just scraping a website or checking an inbox, it probably doesn't."

Option B: Reduce frequency

What it does: Fewer runs = fewer tokens. Linear relationship.

How to decide: Ask the user: "What's the acceptable delay for this job? If something happens, how quickly does it need to be caught — 15 minutes? 30? An hour?"

Common frequency adjustments:

# Change interval
openclaw cron edit <JOB_ID> --every 30m
openclaw cron edit <JOB_ID> --every 1h

# Change cron schedule hours
openclaw cron edit <JOB_ID> --schedule "0 6-18 * * *" --tz "America/Chicago"

Option C: Delete redundant crons

What it does: If two crons do the same work (e.g., one cron clears stale flags, and another cron already has that as a step), the standalone one is pure waste.

How to find: Compare cron prompts side by side. Look for overlapping steps.

openclaw cron rm <JOB_ID>

Always ask before deleting. Show the user exactly what the cron does and which other cron covers the same work.

Option D: Tighten "nothing found" output

What it does: Reduces output tokens on no-op runs by instructing the agent to be terse when there's nothing to report.

How to apply: Add to the end of the cron prompt:

IMPORTANT: If nothing qualifies for action, respond with ONLY: "No new [items]." Do not list, summarize, or explain what was skipped.

Ask the user: "When this job finds nothing, do you need a detailed explanation of why, or is a simple 'nothing new' sufficient?"

Caution: Editing a cron's --message replaces the entire prompt. Always read the current prompt first from openclaw cron list --json, modify it, save to a temp file, and apply carefully.

Option E: Persistent sessions for stateful crons

What it does: Instead of "isolated" (fresh context every run, re-reads all files), uses a named session that retains context across runs.

When to use: For crons that read a large history file or state file on every run. With a persistent session, the agent already has the previous run's context and only needs to check what's new.

openclaw cron edit <JOB_ID> --session-target "session:my-monitor"

Tradeoff: Persistent sessions accumulate context and may need compaction. The default sessionRetention: "24h" handles cleanup. Ask the user if they're comfortable with this tradeoff.

Option F: Model selection

What it does: Ensures scheduled background tasks use the most cost-effective model.

Sonnet should be the default for crons. Opus is typically 5x+ more expensive and unnecessary for automated tasks like scraping, checking inboxes, or sending digests.

Ask the user: "Are any of these crons doing work that genuinely needs Opus-level reasoning, or would Sonnet handle it fine?"


Phase 6: Apply Changes

ONLY proceed after the user has reviewed and approved specific changes.

Pre-change checklist

  • [ ] Recorded baseline daily token estimate
  • [ ] Listed all proposed changes with expected savings
  • [ ] User has approved each change

Apply each change

For each approved change, apply it and confirm:

openclaw cron edit <JOB_ID> <flags>

Post-change verification

  • [ ] Wait for 2-3 runs of each modified cron
  • [ ] Pull fresh run data: openclaw cron runs --id <ID> --limit 3
  • [ ] Compare total_tokens to baseline
  • [ ] Check tail -50 ~/.openclaw/logs/gateway.log for errors
  • [ ] Confirm the cron is still producing correct output (read the summary field)

Present results

Show a before/after comparison:

| Job             | Before (tokens/run) | After (tokens/run) | Before (daily) | After (daily) | Savings |
|-----------------|--------------------|--------------------|----------------|---------------|---------|
| ...             | ...                | ...                | ...            | ...           | ...     |

Quick Reference: CLI Commands

# List all cron jobs with full details
openclaw cron list --json

# Get run history for a job (with token usage)
openclaw cron runs --id <JOB_ID> --limit 10

# Check cron scheduler health
openclaw cron status

# Run a job manually for testing
openclaw cron run <JOB_ID> --expect-final --timeout 120000

# Edit job scheduling
openclaw cron edit <JOB_ID> --every 30m
openclaw cron edit <JOB_ID> --schedule "0 6-18 * * *" --tz "America/Chicago"
openclaw cron edit <JOB_ID> --light-context

# Enable/disable without deleting
openclaw cron disable <JOB_ID>
openclaw cron enable <JOB_ID>

# Delete a job (irreversible)
openclaw cron rm <JOB_ID>

# View full config
cat ~/.openclaw/openclaw.json

# View sessions
openclaw sessions --json
openclaw sessions --active 60   # active in last 60 min

# Gateway log
tail -300 ~/.openclaw/logs/gateway.log

# Session trace files
ls ~/.openclaw/agents/main/sessions/
cat ~/.openclaw/agents/main/sessions/<sessionId>.jsonl

Troubleshooting

High total_tokens but low input_tokens + output_tokens

The gap is system prompt overhead (SOUL.md, USER.md, tool defs, plugins). This is the #1 optimization target. Apply lightContext: true.

JSON parsing fails on CLI output

OpenClaw CLI prints config warnings to stdout before JSON. Strip everything before the first { or [ when parsing programmatically.

openclaw command not found

If installed via Homebrew: export PATH=/opt/homebrew/bin:$PATH

Config warnings: "plugin id mismatch"

Cosmetic. The plugin manifest name doesn't match the config entry. Doesn't affect functionality.

Cron edits not taking effect

The gateway hot-reloads most cron config changes. If it doesn't pick up:

# macOS LaunchAgent restart
launchctl kickstart -k gui/$(id -u)/ai.openclaw.gateway

# Or if using systemd
sudo systemctl restart openclaw-gateway

Rate limit errors after optimization

If the user was previously hitting rate limits and the optimization significantly reduces usage, the issue may resolve on its own. Monitor for 24 hours after changes. If still hitting limits, the issue may be the plan tier itself, not the cron efficiency.


Key Concepts to Explain to Users

System prompt overhead: Every time an isolated cron runs, the full system context (personality files, tool definitions, plugin manifests) is sent to the API as the system prompt. This happens before the agent reads a single word of your cron instructions. On a typical OpenClaw setup, this is 30-60K tokens — and it's the same 30-60K tokens on every run. lightContext: true eliminates most of this.

Isolated vs persistent sessions: "isolated" means every cron run starts with zero memory of previous runs. The agent re-reads files, re-discovers state, re-processes history from scratch. "session:name" means the agent remembers what happened last time. Use isolated for truly independent tasks. Use persistent for monitoring jobs that check "what's new since last time."

Output token waste: When a monitoring job finds nothing, the agent often writes a detailed report explaining what it checked and why nothing qualified. This can be 3-25K tokens of output that nobody reads. A single-line "nothing new" directive in the prompt eliminates this.

Plugin tax: Every enabled plugin adds its tool definitions to the system prompt of every agent session — including cron runs that never use those tools. If a plugin is enabled with 7 tools, and you have 96 cron runs per day that never call those tools, that's 96 × (tool definition tokens) wasted.

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

70.31%
按下载量换算880

安全审计

VirusTotal

通过

ClawScan

可疑

Static analysis

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills