← Back to Skills Marketplace
paoloxiamn

LX Agent Optimizer

by PaoloXiaMN · GitHub ↗ · v1.4.0 · MIT-0
cross-platform ✓ Security Clean
204
Downloads
2
Stars
0
Active Installs
5
Versions
Install in OpenClaw
/install lx-agent-optimizer
Description
A battle-tested agent self-improvement system built by a non-coder from weeks of real-world usage with OpenClaw. No fluff, no theory — every rule here was le...
README (SKILL.md)

LX Agent Optimizer

A unified skill for agents that want to learn, act proactively, run lean, and cost less — built from real production experience, not theory.

Born from weeks of real usage by Paolo + LX (OpenClaw). Every pattern here was tested, broke something, got fixed, and survived.

Notably: this skill was created by a non-coder author. That is exactly why it is practical — it focuses on observable failures, reusable workflows, and user experience, instead of abstract agent philosophy.


Four Pillars

1. 🧠 Behavior Learning

Learn from real mistakes. Write them down. Review weekly. Change behavior.

→ See references/behavior-learning.md

2. 🎯 Proactive Patterns

Know when to speak up, when to stay silent, and when to just do it.

→ See references/proactive-patterns.md

3. ⚙️ Cron Discipline

Script-first cron jobs that are silent on success, reliable, and cheap.

→ See references/cron-discipline.md

4. 💰 Cost Control

Token spend is real. Route models wisely, cache aggressively, stay lean.

→ See references/cost-control.md


Quick Start

Step 1: Set up improvement log

touch ~/.openclaw/workspace/improvement_log.md

Add this header:

# Agent Improvement Log
Record weekly: problems encountered, lessons learned, behavior changes.

Step 2: Add weekly analysis cron (main session)

{
  "name": "Weekly Self-Improvement",
  "schedule": { "kind": "cron", "expr": "0 9 * * 1", "tz": "Asia/Shanghai" },
  "sessionTarget": "main",
  "payload": {
    "kind": "systemEvent",
    "text": "⏰ Weekly improvement: read improvement_log.md, review last week's problems, add 2-3 new lessons, send brief report to user."
  }
}

Step 3: Run the optimizer audit

Say: "audit my agent setup" — the skill will analyze your workspace and propose improvements.


Core Rules (Non-Negotiable)

These were learned the hard way:

Rule Why
File writes → main session only work agents can't write files; main session can
Data fetch → validate with curl first SPAs return empty shells; APIs return 403; test before shipping
Debugging → internal, not exposed User sees results, not "trying A... trying B..."
Infer before asking Read filenames, context, history — ask only when truly ambiguous
Script-first cron Embed logic in .py files, not in cron message prompts
Silent on success Only alert on anomalies, errors, or changes
Channel health checks → real-time probe, not stale logs Historical cron errors may be old; verify current channel state before alerting or auto-remediating
Cron alerts → classify error type before paging user Delivery failure, task logic failure, and node failure need different handling; don't treat them as the same outage
Reminder source mapping → check both cron and HEARTBEAT.md Some reminders live in cron jobs, others live in heartbeat rules; disabling one side is not enough
Success once ≠ learned A task is only truly learned after the verified path is written into external memory (TOOLS.md, improvement log, or long-term memory)

Tool Path Memory (Verified)

Task Use This Not This
Token usage data ~/.openclaw/agents/*/sessions/*.jsonl codexbar, gateway.log
WeChat article body agent-browser eval "document.querySelector('#js_content')?.innerText" Built-in browser tool
PDF image extraction pdfimages -j \x3Cfile> /tmp/out pymupdf (not installed)
Send image to user message tool (media/filePath) Absolute/~ paths
Sports data (no API key) ESPN public API sofascore (403), official site (SPA)
Apple Calendar today events Run python3 /Users/paolo/.openclaw/workspace/skills/calendar-morning/scripts/today_events.py on Paolo's Mac mini; under the hood it uses /usr/bin/osascript + Calendar.app Re-guessing the tool, calendar names, or prompting from scratch
Telegram channel health check Send a silent real-time probe via message tool and only remediate/alert on actual send failure Scanning historical cron lastError / deliveryStatus and assuming the channel is currently down
Cron anomaly triage First classify as delivery failure / task failure / node failure, then decide whether to alert, retry, or remediate Treating every consecutiveErrors > 0 as the same kind of outage
Reminder disable audit Check both cron jobs and HEARTBEAT.md before saying a reminder is removed Looking only at cron list and missing heartbeat-driven reminders

Weekly Improvement Cycle

Monday 9:00 AM
    ↓
Read improvement_log.md
    ↓
Review last week's conversations for:
  - Tasks that needed retries
  - Times user waited too long
  - Wrong tool choices
  - Repeated mistakes
    ↓
Write 2-3 new lessons to improvement_log.md
    ↓
Send brief report: "N problems this week, key lesson: X, focus next week: Y"

Proactive Trigger Rules

Reach out when:

  • Important email or calendar event incoming (\x3C 2h)
  • Cron task failed with consecutive errors
  • Something discovered user would want to know
  • Haven't spoken in > 8h during waking hours

Stay silent when:

  • Late night (23:00–08:00) unless urgent
  • User is clearly busy
  • Nothing new since last check
  • Just checked \x3C 30 min ago
  • Task succeeded (success = silent)

Do without asking:

  • Read files, search, organize
  • Execute cron/heartbeat checks
  • Update memory and logs
  • Commit workspace changes

Always ask first:

  • Send emails, tweets, public posts
  • Delete data
  • Spend money
  • Make commitments for the user

Heartbeat Design

Heartbeat = control plane only (cheap).

✅ Good heartbeat tasks:

  • Check cron consecutiveErrors
  • Classify cron errors by type (delivery / task / node) before deciding whether to alert
  • Check if Telegram channel is down
  • Quick calendar scan

❌ Move to isolated cron instead:

  • Heavy data fetching
  • Report generation
  • Multi-tool workflows
HEARTBEAT_OK  ← 99% of the time
Alert only when: errors > 0, channel down, something changed

Important: heartbeat may use cron error state to spot anomalies, but must not auto-remediate Telegram/channel issues from stale cron history alone. Use cron state to detect "something looks wrong," then verify with a live probe before fallback alerts or recovery actions.


Cron Design Checklist

Before shipping any cron job:

  • Logic is in a .py script, not embedded in the prompt
  • Script tested locally with python3 script.py
  • Silent on success (exit(0) with no output = no message sent)
  • Output is minimal (\x3C 200 chars for routine alerts)
  • Model is cheapest tier that works (e.g., qwen-plus for simple tasks)
  • Timeout is realistic (not too short = retries, not too long = waste)
  • File writes use main session, not work agent
  • Validated data source with curl before embedding URL

Model Selection Guide

Task Type Recommended Tier Example
Simple fetch + format cheapest (qwen-plus / gemini-lite) sports results, reminders, weather
固定流程任务(文章总结、写文件、数据抓取) qwen-plus 微信文章总结、Obsidian 写入、cron 推送
中文内容处理(总结/整理/改写) qwen-plus 中文语境更准,比 claude 省 token
周复盘 / cron 状态检查 gemini-2.5-flash 够用,比 sonnet 便宜
Reasoning + writing mid-tier (sonnet) self-improvement analysis, strategy
Complex multi-step high-tier (opus) only when mid-tier fails repeatedly

分工原则:主 session(claude)只做判断+调度+对话;固定流程和中文任务一律 sessions_spawn → qwen-plus。

主模型注意事项(2026-03-28):

  • 不要把 Gemini 设为主 session 默认模型 → compaction.mode: safeguard 与 Gemini preview 模型有 API 兼容性问题,导致 400 报错
  • Gemini 适合做 fallback 或在 isolated cron 中指定使用
  • 主 session 保持 renlijia/claude-sonnet-4-6

Cost rule: Cache hit rate > 70% = healthy. If \x3C 40%, you're creating too many new sessions.


Files

  • references/behavior-learning.md — improvement log format and weekly cycle
  • references/proactive-patterns.md — when to act, when to stay quiet
  • references/cron-discipline.md — script-first cron patterns, error classification, and channel-health rules
  • references/cost-control.md — token cost reduction playbook
  • scripts/token_report.py — weekly token usage report script

Hermes-Inspired Extensions(v1.4)

三个从 Hermes Agent 框架借鉴的自进化机制,补充原有四大支柱。

5. 📋 Skill Awareness(技能感知层)

Agent 应该主动知道自己有什么能力,而不是靠记忆猜。

每周扫描机制:

ls /Users/paolo/.openclaw/workspace/skills/

扫描后更新 memory/skill-registry.md,格式:

# Skill Registry(更新日期:YYYY-MM-DD)
- skill-name: 一句话描述,适用场景

触发规则:

  • 每周一自检一次,有新 Skill 时更新
  • 接到任务前先查 skill-registry.md,判断是否有现成 Skill 可用
  • 优先复用已验证的 Skill,不要重新摸索相同路径

6. 🔁 Memory Recall Gate(记忆召回门控)

在处理较复杂任务前,先主动搜索记忆库,复用已有成功路径。

执行流程:

接到任务
  ↓
memory_search(关键词:任务类型 + 工具名)
  ↓
命中成功路径?
  ├── 是 → 直接复用,记录为"路径复用"
  └── 否 → 重新执行,执行完后记录路径到 TOOLS.md 或 improvement_log.md

规则:

  • 命中率低(连续 3 次同类任务都没命中记忆)→ 说明记忆库记录不足,补录
  • 禁止"凭印象试错":有相似历史路径一定先查,再动手
  • 验证路径写入格式:TOOLS.md | 已验证工具路径 表格

7. 📊 Task Quality Signal(任务质量反馈)

每次执行较复杂任务后,记录结果质量,形成可追踪的成功率数据。

记录格式(追加到 improvement_log.md):

## Task Signal(YYYY-MM-DD)
- 任务:[任务简述]
- 结果:✅ 成功 / ⚠️ 部分成功 / ❌ 失败
- 是否重试:否 / 是(N次)
- 关键路径:[用了什么工具/命令]
- 教训(失败时):[一句话]

什么算"较复杂任务":

  • 调用超过 2 个工具
  • 涉及文件写入 / cron 变更 / 外部 API
  • 用户明确说"帮我做XX"

周报中汇报:

本周任务信号:共 N 次,成功率 X%,重试 Y 次,最高频失败点:Z

Usage Guidance
This skill is internally coherent for agent self‑improvement: it will read your OpenClaw session logs (~/.openclaw/agents/*/sessions/*.jsonl) and may write ~/.openclaw/workspace/improvement_log.md and suggest cron jobs that run local scripts. Before installing, confirm you are comfortable with it reading your local session/conversation logs and with any cron tasks it suggests (they may send proactive messages using your agent's message tool). The included token_report.py is small and only parses local JSONL session files and prints summaries. If you want tighter control, run token_report.py manually first, inspect the SKILL.md and references files, and avoid enabling any cron payloads that would send messages or run scripts until you review them.
Capability Analysis
Type: OpenClaw Skill Name: lx-agent-optimizer Version: 1.4.0 The lx-agent-optimizer skill bundle is a legitimate framework designed to improve agent efficiency, reduce token costs, and manage cron jobs. The core logic involves setting up a local improvement log and a token usage reporting script (scripts/token_report.py) that parses local session logs to provide cost analytics. While the script accesses sensitive conversation logs, it does so locally to aggregate usage metrics without any evidence of data exfiltration or malicious intent. The instructions in SKILL.md and the reference files focus on operational best practices, such as error classification and model routing, and do not contain harmful prompt injections or unauthorized persistence mechanisms.
Capability Tags
cryptorequires-sensitive-credentials
Capability Assessment
Purpose & Capability
The name/description (agent self‑improvement, cost control, cron discipline) match what the skill actually does: it reads agent session logs, recommends cron/script patterns, writes an improvement_log, and ships a local token_report.py for weekly token audits.
Instruction Scope
SKILL.md instructs the agent to read and review user conversation history and files (e.g., ~/.openclaw/workspace/improvement_log.md and sessions JSONL under ~/.openclaw/agents/*/sessions). That access is relevant to the stated purpose but means the skill will examine local session logs and workspace files — users should be aware it inspects conversation/session data.
Install Mechanism
No install spec (instruction-only) and a small included script (token_report.py). Nothing is downloaded or written by an installer; risk from installation is minimal.
Credentials
The skill requests no environment variables or credentials. Its file reads/writes are limited to OpenClaw workspace and agent session files, which are appropriate for token auditing and behavior learning.
Persistence & Privilege
always:false and default autonomous invocation are used. The skill does not demand permanent system presence or modify other skills' configs. It proposes cron tasks and writing an improvement log (expected for this purpose).
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install lx-agent-optimizer
  3. After installation, invoke the skill by name or use /lx-agent-optimizer
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.4.0
v1.4: Added Hermes-inspired self-evolution extensions — Skill Awareness (weekly skill registry scan), Memory Recall Gate (search memory before acting, reuse verified paths), Task Quality Signal (track success rate per task type). Agent now learns proactively instead of just fixing mistakes reactively.
v1.3.0
v1.3.0: 新增 False Positive Prevention 规则(通道检查用实时探测代替历史日志扫描);补充 Reminder 来源审查清单(cron + HEARTBEAT.md 双检);Silent Automation Contract 强化;强调非编程作者背景;优化 description 说明
v1.1.1
v1.1.1: Added external memory rule — Success once ≠ Learned. Core problem: AI agents restart fresh each session. Even after successfully completing a task (e.g. reading Apple Calendar, fetching data), the agent may fumble the same task next time if the verified path is not written down. New rule added to Core Rules (rule #7): A task is only truly learned after the verified path is written into external memory — TOOLS.md, improvement_log.md, or long-term MEMORY.md. Trigger: externalize any workflow that is (1) already verified, (2) likely to repeat, (3) has easy-to-forget details. Three-layer external memory structure: - TOOLS.md: verified tool paths, entry commands, do-not-detour conclusions - improvement_log.md: pit-fall records, weekly improvement notes - MEMORY.md: long-term rules and preferences explicitly requested by the user behavior-learning.md updated: promotion rules now include — verified repeatable workflows promote immediately to TOOLS.md (no need to wait for 3 occurrences); user-explicit long-term preferences also sync to MEMORY.md. New definition of done: task success + verified path externalized = truly learned.
v1.1.0
Add external-memory rule: success once does not mean learned; promote verified reusable workflows to TOOLS.md and long-term memory when appropriate.
v1.0.0
Initial release: battle-tested agent optimization from real production usage. Covers behavior learning, proactive patterns, cron discipline, and cost control.
Metadata
Slug lx-agent-optimizer
Version 1.4.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 5
Frequently Asked Questions

What is LX Agent Optimizer?

A battle-tested agent self-improvement system built by a non-coder from weeks of real-world usage with OpenClaw. No fluff, no theory — every rule here was le... It is an AI Agent Skill for Claude Code / OpenClaw, with 204 downloads so far.

How do I install LX Agent Optimizer?

Run "/install lx-agent-optimizer" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is LX Agent Optimizer free?

Yes, LX Agent Optimizer is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does LX Agent Optimizer support?

LX Agent Optimizer is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created LX Agent Optimizer?

It is built and maintained by PaoloXiaMN (@paoloxiamn); the current version is v1.4.0.

💬 Comments