← 返回 Skills 市场
jx-76

OpenClaw Token Saver

作者 jjx · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ⚠ suspicious
249
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install jx76-openclaw-token-saver
功能描述
OpenClaw Token 节省指南。提供5大类20+种减少Token消耗的方法,包括上下文瘦身、工具优化、缓存复用、模型控制和本地替代方案。当Token使用超过阈值时自动触发优化建议。
使用说明 (SKILL.md)

OpenClaw Token 节省指南

降低 OpenClaw 使用成本的完整策略手册。

自动触发条件

当以下情况发生时,自动调用此 skill:

  1. Token 使用超过 80% - 触发优化建议
  2. 单次请求超过 4000 tokens - 建议压缩上下文
  3. 上下文接近上限 - 自动提示清理方案
  4. 连续 10 轮对话 - 建议压缩或重置

自动响应逻辑

IF token_usage > 80%:
    → 显示警告 + 提供压缩选项
    → 建议使用 /compact
    → 推荐切换到 /nc 模式

IF token_per_turn > 4000:
    → 提示精简输入
    → 建议分批处理
    → 启用工具返回限制

IF context_window > 90%:
    → 强制建议清理
    → 提供 /reset 选项
    → 显示当前 Token 统计

一、上下文瘦身

1. 手动压缩

  • 对话中发送 /compact
  • 自动将长历史转为摘要

2. 滑动窗口

{
  "max_history_messages": 10
}

只保留最近 N 条消息

3. 分层上下文切换

命令 作用
/nc 仅当前+系统提示
/cc 最近10条
/fc 全量上下文

4. 重置/新建

  • /reset - 清空当前会话,保留记忆
  • /new - 开启全新对话

5. 自动压缩

安装 claw-compact

clawhub install claw-compact

满15轮或5000 token自动压缩


二、工具与提示词优化

6. 禁用无用工具

只开启必要工具:

{
  "tools": {
    "enabled": ["read", "write", "exec"]
  }
}

系统提示词可从 3500 → 800 token

7. 精简 Skill 描述

  • 技能 YAML frontmatter 保持简洁
  • 描述控制在 100 字以内

8. 限制工具返回

强制工具返回摘要:

{
  "web_search": {
    "max_results": 3,
    "max_chars": 500
  }
}

9. 精简系统提示

{
  "bootstrapMaxChars": 2000
}

三、缓存与复用

10. 开启模型缓存

利用 Anthropic 提示缓存:

{
  "model": "claude-3-sonnet",
  "enable_prompt_caching": true
}

11. 心跳保活

缓存 TTL 1h 时,设置 55min 心跳:

{
  "heartbeat": {
    "interval_minutes": 55
  }
}

12. 本地检索替代

安装 qmd 本地索引:

clawhub install qmd

只取需要的段落,节省 80%+

13. 搜索优化

使用 exa-search

clawhub install exa-search

过滤广告/HTML,返回纯文本,省 70%+


四、模型与调用控制

14. 模型分层

任务类型 推荐模型
简单计算/查天气 GPT-3.5 / Haiku
代码生成 GPT-4 / Sonnet
复杂推理 GPT-4o / Opus

15. 关闭重试/兜底

{
  "max_retries": 0,
  "enable_fallback": false
}

16. 限制迭代次数

{
  "max_iterations": 10
}

17. Token 预算

{
  "token_budget": {
    "per_turn": 4000,
    "per_session": 50000
  }
}

五、本地替代

18. 本地部署模型

使用 Ollama:

ollama run qwen2.5:14b

配置 OpenClaw 连接本地:

{
  "model": {
    "provider": "ollama",
    "base_url": "http://localhost:11434"
  }
}

Token 费用为 0

19. 本地代理转发

Node.js 协议转换:

// 走网页版 AI,不耗官方 Token

20. 批量处理

将多个小任务合并为一次请求:

❌ 10次单独请求
✅ 1次批量处理

快速检查清单

  • 配置 max_history_messages: 10
  • 禁用不需要的 tools
  • 安装 claw-compact
  • 设置 Token 预算
  • 使用 /compact 定期压缩
  • 考虑本地模型替代

参考配置

{
  "context": {
    "max_history_messages": 10,
    "auto_compact": true
  },
  "tools": {
    "enabled": ["read", "write", "exec", "web_search"]
  },
  "model": {
    "default": "gpt-3.5-turbo",
    "complex_tasks": "gpt-4"
  },
  "limits": {
    "max_retries": 0,
    "max_iterations": 10,
    "token_budget_per_session": 50000
  }
}

预计节省: 50-90% Token 消耗

安全使用建议
This skill appears to be a genuine token‑saving guide, but before installing or following its commands consider the following: - Do NOT blindly run curl | sh or other remote installers; review the installer contents and prefer vendor documentation or pinned releases. - Avoid enabling powerful tools (exec, write, read) for an untrusted skill — these let code read/write files and execute commands on your machine. - The SKILL.md suggests a local proxy to avoid 'official' token accounting; that may violate provider terms or lead to unexpected billing/behavior — only use such approaches if you understand the legal/billing implications. - If you want to try the included monitoring, inspect scripts/token-monitor.py locally (it is simple and benign) and run it in a sandbox before enabling any automatic actions. - Prefer installing third‑party components from trusted sources (official GitHub releases, distro packages) and review their permissions. If you want to proceed: run the monitor manually first, do not enable exec/write for the skill, and avoid running unreviewed install scripts.
功能分析
Type: OpenClaw Skill Name: jx76-openclaw-token-saver Version: 1.0.1 The skill bundle is a legitimate utility designed to help users monitor and reduce token consumption in OpenClaw. It includes a Python monitoring script (scripts/token-monitor.py) that generates usage reports and a configuration file (config/token-saver.json) for setting optimization thresholds. The instructions in SKILL.md and README.md provide helpful strategies such as context compression and local model integration (Ollama) without any evidence of malicious intent, data exfiltration, or unauthorized execution.
能力评估
Purpose & Capability
The name/description (token savings) match the provided logic and the included token-monitor.py script. However, the guidance includes recommendations to install additional packages, enable exec/read/write tools, and run local model/proxy setups — capabilities that go beyond read-only guidance and require elevated privileges or new software. Those extra recommendations are plausible for a token‑saving tool but are broader than a pure documentation-only skill.
Instruction Scope
SKILL.md explicitly instructs operators to install third‑party components (claw-compact, qmd, exa-search, Ollama), to enable tools like exec/read/write/web_search, and to run a Node.js proxy for forwarding web AI calls. These instructions direct running external installers and enabling execution capabilities and also suggest workarounds to avoid official token accounting — actions that access system resources and could be misused or have side effects beyond token optimization.
Install Mechanism
The registry has no formal install spec, but the README and SKILL.md recommend running installers and one‑line installers (e.g., curl -fsSL https://ollama.com/install.sh | sh) and clawhub install commands. Recommending curl|sh and installing packages from unspecified taps is higher risk than pure instruction-only content because it leads operators to execute remote code without a pinned, trusted release.
Credentials
The skill declares no required environment variables or credentials (good), and the included Python script does not access secrets or external endpoints. Still, the guidance to enable 'exec'/'read'/'write' tools and to run local proxies is disproportionate to a simple passive guide: enabling these tools grants system access which is not strictly necessary to produce textual optimization tips.
Persistence & Privilege
always is false and there are no declared config paths or credentials the skill will persistently claim. The skill includes a monitoring script and a config example, but it does not request forced installation or elevated platform privileges in the registry metadata.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install jx76-openclaw-token-saver
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /jx76-openclaw-token-saver 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
Add tags for better discovery
v1.0.0
Initial release
元数据
Slug jx76-openclaw-token-saver
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

OpenClaw Token Saver 是什么?

OpenClaw Token 节省指南。提供5大类20+种减少Token消耗的方法,包括上下文瘦身、工具优化、缓存复用、模型控制和本地替代方案。当Token使用超过阈值时自动触发优化建议。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 249 次。

如何安装 OpenClaw Token Saver?

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

OpenClaw Token Saver 是免费的吗?

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

OpenClaw Token Saver 支持哪些平台?

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

谁开发了 OpenClaw Token Saver?

由 jjx(@jx-76)开发并维护,当前版本 v1.0.1。

💬 留言讨论