Files
rtk-ai__rtk/openclaw
Adrien Eppling a1673f7428 docs: scope savings claims to bash output and document the estimator
RTK was documented as delivering "60-90% token savings", which reads as a
cost reduction. What RTK actually reduces is bash output bytes. Those are
one contributor to input tokens, which are themselves only part of a bill
that also counts output tokens, so the reduction dilutes at every step.

- add docs/guide/resources/savings-explained.md as the canonical explainer:
  the savings chain, both estimators, and what RTK does not reduce
- rescope the headline claim across README (7 languages), the guide, hook
  rules, agent definitions and module READMEs
- relabel per-command tables as bash output reduction, keeping every figure
- document that reported tokens are estimates: rtk gain uses bytes/4
  (src/core/tracking.rs), filter tests use split_whitespace().count().
  Neither is a real tokenizer, so ratios hold but absolute counts do not

Remove figures that had no source: the $3/Mtok constant and its $36
example, the +/-10% tokenization accuracy claim, the 99.5% hook-install
figure, the invented session tables in README and INSTALL, and the 30-50%
parser range.

CHANGELOG is untouched. Shipped release notes stay as a historical record.
2026-07-22 18:33:54 +02:00
..

RTK Plugin for OpenClaw

Transparently rewrites shell commands executed via OpenClaw's exec tool to their RTK equivalents, cutting up to 90% of the bash output that reaches the LLM context.

This is the OpenClaw equivalent of the Claude Code hooks in hooks/rtk-rewrite.sh.

How it works

The plugin registers a before_tool_call hook that intercepts exec tool calls. When the agent runs a command like git status, the plugin delegates to rtk rewrite which returns the optimized command (e.g. rtk git status). The compressed output enters the agent's context window, saving tokens.

All rewrite logic lives in RTK itself (rtk rewrite). This plugin is a thin delegate -- when new filters are added to RTK, the plugin picks them up automatically with zero changes.

Installation

Prerequisites

RTK must be installed and available in $PATH:

brew install rtk
# or
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh

Install the plugin

# Copy the plugin to OpenClaw's extensions directory
mkdir -p ~/.openclaw/extensions/rtk-rewrite
cp openclaw/index.ts openclaw/openclaw.plugin.json ~/.openclaw/extensions/rtk-rewrite/

# Restart the gateway
openclaw gateway restart

Or install via OpenClaw CLI

openclaw plugins install ./openclaw

Configuration

In openclaw.json:

{
  plugins: {
    entries: {
      "rtk-rewrite": {
        enabled: true,
        config: {
          enabled: true,    // Toggle rewriting on/off
          verbose: false     // Log rewrites to console
        }
      }
    }
  }
}

What gets rewritten

Everything that rtk rewrite supports (30+ commands). See the full command list.

What's NOT rewritten

Handled by rtk rewrite guards:

  • Commands already using rtk
  • Piped commands (|, &&, ;)
  • Heredocs (<<)
  • Commands without an RTK filter

Measured savings

Command Output reduction
git log --stat 87%
ls -la 78%
git status 66%
grep (single file) 52%
find -name 48%

License

Apache 2.0 -- same as RTK.