← 返回
安全合规 中文

OpenClaw Token Optimizer

Optimize OpenClaw token usage and cost by auditing context injection, trimming workspace files (AGENTS.md/SOUL.md/MEMORY.md and daily memory), enabling promp...
通过审计上下文注入、精简工作区文件(AGENTS.md/SOUL.md/MEMORY.md 及每日记忆)并启用提示优化,来优化 OpenClaw 的 Token 用量与成本。
ccjingeth
安全合规 clawhub v1.0.0 1 版本 99554 Key: 无需
★ 3
Stars
📥 4,627
下载
💾 10
安装
1
版本
#latest

概述

OpenClaw Token Optimizer

Overview

Deliver a practical audit and configuration plan that cuts input tokens and unnecessary calls while keeping answer quality. Provide concrete config edits, workspace file trimming guidance, and a prioritized rollout plan.

Workflow

1) Scope and locate configuration

  • Identify the OpenClaw config file location (common paths include ~/.openclaw/openclaw.json, .openclaw/openclaw.json, or project root config).
  • List injected workspace files in scope (e.g., AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, HEARTBEAT.md, MEMORY.md, and memory/YYYY-MM-DD.md).
  • Confirm provider and model support for prompt caching and memory search to avoid proposing unsupported keys.

2) Baseline token sources

  • Break input cost into buckets: system prompt, tool schema, workspace files, memory files, and conversation history.
  • Use a rough sizing method if exact token counts are unavailable (e.g., characters/4 as a quick estimate) and call out that the estimate is approximate.

3) Input reduction (highest ROI)

  • Trim workspace files first. Target budgets:
  • AGENTS.md: keep only essential agent rules and policies.
  • SOUL.md: reduce to short persona bullets.
  • MEMORY.md: keep durable facts only; archive the rest.
  • memory/YYYY-MM-DD.md: prune or rotate daily logs.
  • Remove unused workspace injections in config (e.g., if TOOLS.md or IDENTITY.md is unused).
  • Prefer memory search over full-file injection for large memories. If using qmd, index only needed paths.

4) Cache and context control

  • Enable prompt caching for the primary model when supported. Set cacheRetention to a long window and keep a consistent system prompt to maximize cache hits.
  • Configure heartbeat to keep the cache warm (e.g., ~55 minutes), using a low-cost model and a minimal heartbeat prompt.
  • Enable context pruning with a TTL that matches the cache window to prevent unbounded history growth.
  • Add compaction with memory flush so long sessions preserve durable decisions while clearing history.

5) Call reduction

  • Audit cron and scheduled tasks. Consolidate overlapping checks, reduce frequency, and move non-creative tasks to cheaper models.
  • Configure delivery to be on-demand or only on change to avoid no-op calls.

6) Model strategy

  • Default to a cost-effective model for routine work and provide aliases for manual upgrades to premium models.
  • Use subagents for parallel, isolated tasks with cheaper models to avoid bloating the main context.

7) Deliverables

Provide:

  • A short audit summary and estimated savings.
  • A concrete config patch or JSON snippet for openclaw.json.
  • A list of files to trim, with before/after size targets.
  • A phased rollout plan (quick wins first, then advanced options).

References

  • Use references/openclaw-token-optimization.md for configuration snippets, checklists, and qmd guidance.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-28 23:07 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 89 📥 30,584
security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,697
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,210 📥 266,145