← 返回 Skills 市场
tryxin

agent-quantizer

作者 Tryxin · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ⚠ suspicious
91
总下载
0
收藏
0
当前安装
3
版本数
在 OpenClaw 中安装
/install agent-quantizer
功能描述
OpenClaw 全栈优化工具包 — Token 统计、上下文压缩、Prompt 精简、僵尸会话清理、心跳检测、Cron 审计、模型分级路由、Skill 分类管理
使用说明 (SKILL.md)

Agent Quantizer - 全栈优化工具包

跨实例部署的 OpenClaw 优化层。不改模型、不改代码,从调用侧省 token、省钱、省时间。

⚡ 自动缓存规则(强制执行)

每次调用工具(web_fetch、web_search、exec 中的网络请求等)之前,必须先查缓存

# 第一步:查缓存
bash ~/.openclaw/skills/agent-quantizer/scripts/cache.sh get "查询内容" \x3C类别>

# 如果返回 HIT → 直接使用,不要重新调用
# 如果返回 MISS → 正常调用工具,调用完后存缓存:

# 第二步:存缓存
bash ~/.openclaw/skills/agent-quantizer/scripts/cache.sh set "查询内容" "结果" \x3C类别> \x3CTTL秒>
类别 TTL 场景
tool 30分钟 天气、汇率等半实时数据
knowledge 24小时 百科、定义等不变信息
realtime 5分钟 新闻等快速变化内容
general 1小时 其他通用查询

📊 Token 统计与扫描

用户说"查看 token 消耗"或"扫描高消耗"时:

# 查看所有 session token 排行
bash ~/.openclaw/skills/agent-quantizer/scripts/quantize.sh stats

# 扫描超阈值 session
bash ~/.openclaw/skills/agent-quantizer/scripts/quantize.sh scan

🧠 上下文压缩

对话变长、响应变慢时:

# 滑动窗口压缩(零 API 消耗)
bash ~/.openclaw/skills/agent-quantizer/scripts/quantize.sh compress \x3Csession_key> --window

# AI 摘要压缩(消耗少量 token,效果更好)
bash ~/.openclaw/skills/agent-quantizer/scripts/quantize.sh compress \x3Csession_key> --ai

✂️ Prompt 精简

精简 prompt 文件,去冗余指令和礼貌用语:

bash ~/.openclaw/skills/agent-quantizer/scripts/quantize.sh trim \x3C文件路径>

🧟 僵尸 Session 清理

清理长期不活跃的 session,回收 token:

# 预览(不删除)
bash ~/.openclaw/skills/agent-quantizer/scripts/clean-zombies.sh 7 --dry-run

# 执行清理(7 天未活动的)
bash ~/.openclaw/skills/agent-quantizer/scripts/clean-zombies.sh 7

# 自定义天数
bash ~/.openclaw/skills/agent-quantizer/scripts/clean-zombies.sh 30

备份在 .zombie-backup/ 目录,删错了可以恢复。

💓 Heartbeat 空转检查

检查 HEARTBEAT.md 是否在空转烧 API:

bash ~/.openclaw/skills/agent-quantizer/scripts/check-heartbeat.sh

标出空的或只有注释的 HEARTBEAT.md,给出修复建议。

⏰ Cron Job 审计

检查定时任务是否有冗余、高频、重复:

bash ~/.openclaw/skills/agent-quantizer/scripts/audit-cron.sh

🎯 模型分级配置

查看当前模型配置和推荐策略:

bash ~/.openclaw/skills/agent-quantizer/scripts/setup-models.sh

📁 Skill 分类整理

扫描所有 skill,建议哪些该放全局、哪些该放专属 workspace:

bash ~/.openclaw/skills/agent-quantizer/scripts/organize-skills.sh

快捷命令

用户可以直接说(中文即可):

  • "查看 token 消耗" / "token 统计" → 执行 quantize stats
  • "扫描高消耗" → 执行 quantize scan
  • "压缩上下文" → 执行 quantize compress
  • "缓存统计" → 执行 quantize cache stats
  • "清空缓存" → 执行 quantize cache flush
  • "清理僵尸 session" → 执行 clean-zombies.sh
  • "检查 heartbeat" → 执行 check-heartbeat.sh
  • "检查 cron" → 执行 audit-cron.sh
  • "整理 skill" → 执行 organize-skills.sh

文件路径

所有脚本位于:~/.openclaw/skills/agent-quantizer/scripts/

scripts/
├── quantize.sh          # 主入口(stats/scan/compress/trim/cache)
├── cache.sh             # 缓存系统
├── clean-zombies.sh     # 僵尸 session 清理
├── check-heartbeat.sh   # heartbeat 空转检查
├── audit-cron.sh        # cron job 审计
├── setup-models.sh      # 模型分级配置
└── organize-skills.sh   # skill 分类整理
安全使用建议
这是一个本地化的“优化/管理”脚本包:功能与说明基本一致,但它会读取并修改 ~/.openclaw 下的会话、agent 状态和 skill 目录,并且在 AI 摘要模式下会通过 openclaw agent 发送消息(会产生模型/API 调用和 token 消耗)。在安装前请:1) 在安全的测试环境或备份好 ~/.openclaw(尤其是 agents/*/sessions 和 workspace 目录);2) 手动审阅 deploy.sh 与各脚本(clean-zombies.sh、organize-skills.sh、quantize.sh 等)确认要执行的移动/删除逻辑;3) 注意依赖:openclaw CLI、jq、python3;4) 如果你不希望脚本修改默认状态目录,可在环境中设置 OPENCLAW_STATE_DIR 指向隔离位置;5) 对于自动移动 skills 的操作,建议先运行脚本的预览/交互模式并确保不会无意中覆盖或公开敏感 skill;最后,如果你不认识作者或不信任来源,先不要在生产环境运行。
功能分析
Type: OpenClaw Skill Name: agent-quantizer Version: 1.0.1 The skill bundle provides legitimate utilities for token optimization and session management, but it contains critical security vulnerabilities that could be exploited for local command execution. Specifically, scripts/cache.sh and scripts/quantize.sh pass unsanitized shell variables (e.g., $query, $text) directly into Python scripts via 'python3 -c' using triple-quoted strings. An attacker or a malicious prompt could use triple-quotes to break out of the Python string literal and execute arbitrary Python code. While the bundle includes helpful features like session backups and token usage statistics, the lack of input sanitization in scripts designed to process arbitrary agent-generated content poses a significant risk.
能力评估
Purpose & Capability
名字/描述与实际脚本高度一致:缓存、上下文压缩、token 统计、僵尸会话清理、heartbeat 检查、cron 审计、模型分级与 skill 整理。未见请求与描述完全不相关的外部凭据或二进制。
Instruction Scope
SKILL.md 和脚本会遍历并读取多个用户目录(~/.openclaw/workspace*、~/.openclaw/agents 等)、调用 openclaw CLI、发送 agent 消息(openclaw agent),并执行会修改状态的操作(移动/删除 session jsonl、写入备份、移动 skill 目录)。这些行为与工具目的相关,但属于高权限本地文件操作,具有潜在破坏性,应谨慎授权并在意外情况下备份。
Install Mechanism
没有从网络下载或安装第三方包;deploy.sh 仅复制本地打包的文件到 ~/.openclaw 并赋可执行权限。没有提到从不受信托的 URL 下载或执行外部代码,风险相对较低。
Credentials
元数据声明不需要环境变量,但脚本使用 OPENCLAW_STATE_DIR(可选)和依赖 HOME/openclaw 配置文件;脚本还会调用 openclaw CLI、python3、jq。按规则,SKILL.md/脚本访问了未在 requires.env 中声明的环境变量与配置路径,应被标注并确认。
Persistence & Privilege
虽然 always=false,脚本会修改其他 skills(organize-skills 会移动 skill 目录到全局)并删除/移动 session 文件(clean-zombies),还会提示重启 gateway。按规则,这类修改其他 skills/系统级目录的行为应被特别注意并在安装前获明确许可。
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install agent-quantizer
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /agent-quantizer 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.2
Agent Quantizer — OpenClaw Full-stack Optimization Toolkit One-sentence positioning: Without modifying the model or code, it helps you save tokens, money, and time from the calling side. Agent Quantizer is an operational optimization skill designed for the long-term running scenarios of OpenClaw. It doesn't touch the model configuration or modify the business logic. Instead, it approaches from the side of the calling link - by counting consumption, compressing context, cleaning up zombies, auditing scheduling, and organizing the skill library - to make the system lighter with use and run more stably over time. Eight tools cover a complete optimization link: Token statistics and scanning → See every single expense clearly Context compression → No matter how long the conversation is, it won't exceed the window limit Prompt streamlining → Remove redundant words and keep the essence Zombie session cleaning → Recover unused resources Heartbeat idle detection → Don't let empty files waste API calls Cron task auditing → Delete or merge scheduled tasks as needed Model hierarchical configuration → Use cheaper models for simple tasks and better models for complex tasks Skill classification and organization → No more chaos among the 42 plugins Core concept: Turn what manual operation and maintenance does into a single command. You focus on the business, and it manages the costs. Agent Quantizer — OpenClaw 全栈优化工具包 一句话定位: 不改模型、不改代码,从调用侧帮你省 Token、省钱、省时间。 Agent Quantizer 是一个面向 OpenClaw 长期运行场景的运维优化 Skill。它不碰模型配置,也不改业务逻辑,而是从调用链路的侧面切入——统计消耗、压缩上下文、清理僵尸、审计调度、整理技能库——让系统越用越轻、越跑越稳。 8 个工具,覆盖一条完整的优化链路: Token 统计与扫描 → 看清每一笔开销 上下文压缩 → 对话再长也不爆窗口 Prompt 精简 → 去掉废话,保留精华 僵尸会话清理 → 回收没人用的资源 心跳空转检测 → 别让空文件白烧 API Cron 任务审计 → 定时任务该删删、该合并合并 模型分级配置 → 简单活走便宜模型,复杂活走好模型 Skill 分类整理 → 42 个插件不再一团乱麻 核心理念: 把人肉运维干的事,变成一句命令。你管业务,它管成本。
v1.0.1
System intelligent management capabilities Token statistics and scanning — Track the Token consumption of each session in real time, accurate to the input/output dimension, to help understand the usage distribution and cost hotspots. Context compression — When the conversation history approaches the upper limit of the context window, automatically perform intelligent summarization and compression on the early content, releasing space while retaining key information to ensure uninterrupted long - term conversations. Prompt streamlining — Structurally slim down the system prompt words and context injection content, removing redundant paragraphs to reduce the basic overhead of each request without sacrificing functionality. Zombie session cleaning — Automatically identify and recycle idle sessions that have been inactive for a long time, releasing memory and connection resources to prevent the system from being slowed down by the "silent burden". Heartbeat idle detection — Determine the health status of sessions and services through a periodic heartbeat detection mechanism. Trigger an alarm or automatically downgrade in case of a long - term non - response to detect and handle problems early. Cron task auditing — Conduct a full - scale inspection of all scheduled tasks: check if the execution frequency is reasonable, if historical executions were successful, and if there are any conflicts or redundancies to ensure that the scheduled task scheduling system is and clean controllable. Model - level configuration — Support assigning different models to different tasks according to scenarios, priorities, or cost strategies. Use lightweight models for simple tasks to save costs and high - end models for complex reasoning to ensure quality, achieving intelligent routing. Skill classification and organization — Perform classified management, version tracking and, dependency sorting on the installed capability plugins to ensure that the skill library has a clear structure, efficient search, and orderly updates. Overall positioning: Let the system manage itself. Instead of relying on people to monitor the operation and maintenance panel, automate these trivial but crucial management tasks. You just use the system, and leave the underlying tidiness to the mechanism. 系统智能管理能力 Token 统计与扫描 — 实时追踪每次会话的 Token 消耗,精确到输入/输出维度,帮助掌握用量分布与成本热点。 上下文压缩 — 当对话历史逼近上下文窗口上限时,自动对早期内容进行智能摘要与压缩,保留关键信息的同时释放空间,确保长对话不中断。 Prompt 精简 — 对系统提示词和上下文注入内容进行结构化瘦身,去除冗余段落,在不损失功能的前提下降低每次请求的基础开销。 僵尸会话清理 — 自动识别并回收长时间无活动的闲置会话,释放内存与连接资源,防止系统被"沉默的负担"拖慢。 心跳空闲检测 — 通过周期性心跳探活机制,判断会话与服务的健康状态。长时间无响应时触发告警或自动降级,做到问题早发现、早处理。 Cron 任务审计 — 对所有定时任务进行全量巡检:执行频率是否合理、历史执行是否成功、是否存在冲突或冗余,确保定时调度体系干净可控。 模型层级配置 — 支持按场景、优先级或成本策略为不同任务分配不同模型。简单走轻量模型省成本,复杂推理走高端模型保质量,实现智能路由。 技能分类与组织 — 对已安装的能力插件进行分类管理、版本追踪和依赖梳理,确保技能库结构清晰、查找高效、更新有序。 整体定位:让系统自己管好自己。不是靠人盯着运维面板,而是把这些琐碎但关键的管理工作自动化,你只管用,底层的整洁交给机制。
v1.0.0
System intelligent management capabilities Token statistics and scanning — Track the Token consumption of each session in real time, accurate to the input/output dimension, to help understand the usage distribution and cost hotspots. Context compression — When the conversation history approaches the upper limit of the context window, automatically perform intelligent summarization and compression on the early content, releasing space while retaining key information to ensure uninterrupted long - term conversations. Prompt streamlining — Structurally slim down the system prompt words and context injection content, removing redundant paragraphs to reduce the basic overhead of each request without sacrificing functionality. Zombie session cleaning — Automatically identify and recycle idle sessions that have been inactive for a long time, releasing memory and connection resources to prevent the system from being slowed down by the "silent burden". Heartbeat idle detection — Determine the health status of sessions and services through a periodic heartbeat detection mechanism. Trigger an alarm or automatically downgrade in case of a long - term non - response to detect and handle problems early. Cron task auditing — Conduct a full - scale inspection of all scheduled tasks: check if the execution frequency is reasonable, if historical executions were successful, and if there are any conflicts or redundancies to ensure that the scheduled task scheduling system is and clean controllable. Model - level configuration — Support assigning different models to different tasks according to scenarios, priorities, or cost strategies. Use lightweight models for simple tasks to save costs and high - end models for complex reasoning to ensure quality, achieving intelligent routing. Skill classification and organization — Perform classified management, version tracking and, dependency sorting on the installed capability plugins to ensure that the skill library has a clear structure, efficient search, and orderly updates. Overall positioning: Let the system manage itself. Instead of relying on people to monitor the operation and maintenance panel, automate these trivial but crucial management tasks. You just use the system, and leave the underlying tidiness to the mechanism. 系统智能管理能力 Token 统计与扫描 — 实时追踪每次会话的 Token 消耗,精确到输入/输出维度,帮助掌握用量分布与成本热点。 上下文压缩 — 当对话历史逼近上下文窗口上限时,自动对早期内容进行智能摘要与压缩,保留关键信息的同时释放空间,确保长对话不中断。 Prompt 精简 — 对系统提示词和上下文注入内容进行结构化瘦身,去除冗余段落,在不损失功能的前提下降低每次请求的基础开销。 僵尸会话清理 — 自动识别并回收长时间无活动的闲置会话,释放内存与连接资源,防止系统被"沉默的负担"拖慢。 心跳空闲检测 — 通过周期性心跳探活机制,判断会话与服务的健康状态。长时间无响应时触发告警或自动降级,做到问题早发现、早处理。 Cron 任务审计 — 对所有定时任务进行全量巡检:执行频率是否合理、历史执行是否成功、是否存在冲突或冗余,确保定时调度体系干净可控。 模型层级配置 — 支持按场景、优先级或成本策略为不同任务分配不同模型。简单走轻量模型省成本,复杂推理走高端模型保质量,实现智能路由。 技能分类与组织 — 对已安装的能力插件进行分类管理、版本追踪和依赖梳理,确保技能库结构清晰、查找高效、更新有序。 整体定位:让系统自己管好自己。不是靠人盯着运维面板,而是把这些琐碎但关键的管理工作自动化,你只管用,底层的整洁交给机制。
元数据
Slug agent-quantizer
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 3
常见问题

agent-quantizer 是什么?

OpenClaw 全栈优化工具包 — Token 统计、上下文压缩、Prompt 精简、僵尸会话清理、心跳检测、Cron 审计、模型分级路由、Skill 分类管理. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 91 次。

如何安装 agent-quantizer?

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

agent-quantizer 是免费的吗?

是的,agent-quantizer 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

agent-quantizer 支持哪些平台?

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

谁开发了 agent-quantizer?

由 Tryxin(@tryxin)开发并维护,当前版本 v1.0.1。

💬 留言讨论