返回顶部
c

context-optimizer上下文优化器

Slash OpenClaw token costs and prevent context overflow. Use whenever the user mentions high API costs, expensive tokens, context truncation, context overflow, slow responses in long sessions, noisy memory recall, bloated bootstrap, or wants to tune openclaw.json for efficiency. Also trigger when the user says their agent "uses too many tokens" or tasks feel "wasteful." This skill is aggressive and opinionated — it gives concrete configs to paste, not menus of knobs.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0-alpha
安全检测
已通过
150
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

context-optimizer

上下文优化器

目标:将输入令牌削减至保持任务质量所需的最小值。

原则:诊断 → 应用单一最高影响修复 → 重新测量 → 重复。

快速路径——使用脚本

使用捆绑脚本快速审计并应用默认设置:

bash
python scripts/context_optimizer.py
python scripts/context_optimizer.py --apply
python scripts/context_optimizer.py --apply --aggressive

该脚本自动检测配置路径,写入后验证,失败时回滚。使用 --config <路径> 指定特定文件。

运行后,通过 /status 和 /usage tokens 验证。

步骤 1——诊断(手动路径)

如果脚本使用不足或不可用,请运行:

/status
/context detail
/usage tokens

识别主要消耗源:引导文件、工具输出、记忆检索或长会话累积。

步骤 2——按影响顺序应用修复

从上到下操作,当使用量可接受时停止。

修复 1:缩小引导文件

精简 AGENTS.md、SOUL.md、TOOLS.md、USER.md、MEMORY.md 和大型技能文件。删除填充内容,将很少需要的细节移至按需读取的参考资料中。

设置更小的引导/图像限制及相关默认值。完整配置示例见 references/configs.md。

修复 2:限制工具输出

减少网络搜索/获取负载,优先使用定向读取(行范围/摘录)而非完整转储。

完整配置示例见 references/configs.md。

修复 3:清理过时工具结果

启用上下文修剪,使较旧的大型工具负载自动过期,同时保持近期轮次完整。

完整配置示例见 references/configs.md。

修复 4:收紧记忆检索

降低召回量并提高相关性阈值;保持去重和近期偏差启用。如果 memorySearch.extraPaths 过于宽泛,则缩小范围。

完整配置示例见 references/configs.md。

修复 5:会话卫生

在会话中使用 /compact,主题切换时使用 /new,恢复无望时使用 /reset。为经常运行较长的会话启用自动压缩。

完整配置示例见 references/configs.md。

步骤 3——验证

每次更改后:

  1. 1. 运行 openclaw config validate。
  2. 如果提示,重启网关。
  3. 重新检查 /status 和 /usage tokens。
  4. 在代表性任务上抽查召回效果。
  5. 如果质量下降,将最近的更改回调一级。

快速参考:症状 → 修复
症状操作
每次轮次都很昂贵,即使是简单轮次修复 1(引导文件)
搜索或文件读取后成本飙升
修复 2(工具输出) |

| 长会话变慢/被截断 | 修复 3(修剪)+ 修复 5(会话卫生) | | 记忆结果感觉嘈杂或不相关 | 修复 4(记忆检索) | | 截图成本高昂 | 修复 1,设置 imageMaxDimensionPx: 512 | | 上下文过大/截断错误 | 修复 5(/compact 或 /new),然后修复 3 |

完整激进一体化配置见 references/aggressive-config.md。
完整命令速查表见 references/commands.md。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 aggressive-context-optimizer-1776364262 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 aggressive-context-optimizer-1776364262 技能

通过命令行安装

skillhub install aggressive-context-optimizer-1776364262

下载

⬇ 下载 context-optimizer v1.0.0-alpha(免费)

文件大小: 7.97 KB | 发布时间: 2026-4-17 13:58

v1.0.0-alpha 最新 2026-4-17 13:58
- Initial alpha release of "context-optimizer" skill.
- Aggressive, opinionated tool for slashing OpenClaw token costs and preventing context overflow.
- Provides step-by-step diagnosis and targeted fixes, focusing on concrete config changes rather than generic options.
- Includes a script for automated optimization and rollback, plus detailed manual optimization guidance.
- Quick-reference table links common symptoms to specific fixes for fast troubleshooting.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部