Cost-optimization buddy for OpenClaw. Make your AI assistant cheaper over time.
ClawBuddy is a cost-optimization plugin for OpenClaw. It works as a transparent proxy that intercepts OpenClaw API calls, collects data in the background, validates cheap model capabilities, and auto-generates Skills — gradually migrating expensive large model calls to cheaper small models without sacrificing task quality.
User → OpenClaw → ClawBuddy proxy (:18790) → Primary API (e.g. glm-5-turbo)
↓
┌──────────────────────┐
│ Background (async) │
│ │
│ Mode 1: Data collection │
│ Mode 2: Mock validation │ ← cheap model (e.g. qwen3.5:9b) + skills
└──────────────────────┘
ClawBuddy launches a local OpenAI-compatible proxy server and modifies the OpenClaw config to point API requests to it. Fully transparent to OpenClaw — it just sees a normal model provider.
Pure data collection, zero intrusion.
- All requests forwarded to the primary model as usual, zero UX change
- Automatically collects complete input/output for every request
- Chains multi-turn requests from the same session into complete task traces
- Auto-labels each task with a cheap model (e.g. "file organization", "code refactoring")
- Export as JSONL / LLaMA-Factory format for fine-tuning your own small model
Best for: Users with GPU resources who want to fundamentally improve small model capabilities through training.
Sandbox validation + auto Skill generation, training-free cost reduction.
Core loop:
Use primary model (glm-5-turbo) for daily tasks
↓ Background collects task traces
Run the same task with cheap model (qwen3.5:9b) in a mock sandbox
↓ Primary model judges the result
pass → Accumulate pass records
fail → Analyze failure → Auto-generate OpenClaw Skill → Re-validate with Skill
↓ Task type accumulates N passes
Dashboard notification → "Poetry writing" validated, suggest switching to cheap model
↓ User enables offload with one click
The primary model is only called at three low-frequency points: generating mock environments, judging results, and generating Skills. Daily labeling is handled entirely by the cheap model.
Best for: Users without GPUs or who prefer prompt engineering over model training.
git clone https://github.com/haochen2115/clawbuddy.git
cd clawbuddy
npm install
npm run build
npm link # Makes 'clawbuddy' command available globallyOne command to start, one to stop:
# Start (auto-backup OpenClaw config, inject proxy, launch services)
clawbuddy start
# Stop (Ctrl+C or run from another terminal)
clawbuddy stopThat's it. After starting, use OpenClaw as usual. Open http://localhost:18791 for the Dashboard.
start automatically:
- Backs up OpenClaw config (first launch only)
- Injects proxy provider into OpenClaw (OpenClaw hot-reloads, no restart needed)
- Launches proxy server + dashboard
stop (or Ctrl+C) automatically:
- Stops all services
- Precisely restores OpenClaw config (only removes proxy-related fields, preserves other changes)
Default config works out of the box, but you can customize via CLI flags:
# Specify mode (default: mode2)
clawbuddy start --mode mode1
# Specify cheap model
clawbuddy start --cheap-provider ollama --cheap-model qwen3.5:9b
# Or edit config file
clawbuddy config set mode mode1
clawbuddy config set cheap_api.model qwen3.5:9b
clawbuddy config show# Export all
clawbuddy export --format jsonl --output ./training_data.jsonl
# Filter by task label
clawbuddy export --label "file organization" --output ./file_org.jsonl
# Export as LLaMA-Factory format
clawbuddy export --format llamafactory --output ./dataset/# Check status
clawbuddy status
# Enable / disable offload
clawbuddy offload enable "poetry writing"
clawbuddy offload disable "poetry writing"
clawbuddy offload listLocal Web Dashboard at http://localhost:18791 with 6 panels:
| Panel | Function |
|---|---|
| Overview | Mode, task counts, recent validations |
| Task Types | Label list, frequency, phase, manual validation trigger |
| Data | Training data stats, label distribution chart, export |
| Validation | Per-label validation details: pass/fail/reason |
| Skills | Auto-generated Skills list, view/delete |
| Router | Control which task types use cheap model offload |
See task counts, request volume, task type count, and validated count at a glance. Recent validation records with pass/fail reasons shown at the bottom.
All auto-classified task labels. View collection count, current phase (collecting → validating → validated → offloaded), pass/fail counts per type, with manual validation trigger.
Browse all collected training data. Filter by label or date, preview user messages and assistant responses. Pie chart shows label distribution. One-click export to JSONL or LLaMA-Factory format.
Detailed validation records. Each entry shows: time, task type, cheap model used, result (pass/fail/not_mockable), and the primary model's specific judgment — e.g. "small model didn't maintain the Banana persona tone" or "small model correctly understood the task intent".
Auto-generated OpenClaw Skills. When the cheap model repeatedly fails at a task type, the primary model analyzes failure patterns and generates targeted SKILL.md files to help the cheap model perform better next time.
Core operations panel. View each task type's routing status (🔵 primary / 🟢 cheap), pass rate, and one-click "Enable Offload" to switch to cheap model or "Disable Offload" to switch back. Supports manual switching at any phase.
clawbuddy/
├── src/
│ ├── index.ts # CLI (commander)
│ ├── proxy/
│ │ ├── server.ts # Hono HTTP server (:18790)
│ │ ├── router.ts # Route decision (primary / cheap)
│ │ ├── filter.ts # Request filter (task / system-level)
│ │ └── token-cache.ts # OAuth token cache (for background tasks)
│ ├── config/
│ │ ├── init.ts # init / restore / config management
│ │ └── types.ts # Type definitions
│ ├── store/
│ │ └── db.ts # SQLite (better-sqlite3)
│ ├── collector/
│ │ ├── collector.ts # Request collection + session chaining
│ │ ├── labeler.ts # Cheap model labeling + merging
│ │ └── exporter.ts # JSONL / LLaMA-Factory export
│ ├── validator/
│ │ ├── sandbox.ts # Mock environment management
│ │ ├── mock-gen.ts # Primary model generates setup scripts
│ │ ├── runner.ts # Cheap model runs in sandbox
│ │ ├── judge.ts # Primary model judges results
│ │ ├── scheduler.ts # Async validation scheduler
│ │ ├── primary-call.ts # Shared primary model caller (with auth)
│ │ └── trace-compress.ts # Task trace compression (truncate system prompts)
│ ├── skills/
│ │ ├── analyzer.ts # Failure pattern analysis
│ │ ├── generator.ts # SKILL.md generation
│ │ └── evidence.ts # Evidence pool + pattern detection
│ └── dashboard/
│ ├── api.ts # REST API
│ └── static/index.ts # Single-page Dashboard
├── docs/
│ └── screenshots/ # Dashboard screenshots
ClawBuddy config file is at ~/.clawbuddy/config.json:
ClawBuddy is compatible with any OpenAI-compatible API:
| Provider | Example | Notes |
|---|---|---|
| Ollama | --cheap-provider ollama --cheap-model qwen3.5:9b |
Local, zero cost |
| Ollama (large) | --cheap-provider ollama --cheap-model qwen3.5:27b |
Local, better quality |
| vLLM | --cheap-base-url http://localhost:8000/v1 |
Self-hosted inference |
| Zhipu AI | --cheap-base-url https://open.bigmodel.cn/api/... |
Cheap Chinese API |
| Gemini Flash | --cheap-base-url ... |
Google's cheap model |
Exported JSONL format:
{"messages": [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}], "metadata": {"task_label": "poetry writing", "session_id": "abc123", "model": "glm-5-turbo", "timestamp": "2026-03-17T10:00:00Z"}}- Zero intrusion on OpenClaw: Only modifies the provider's baseUrl in config, no OpenClaw source code changes
- Additive only: Generated Skills use
clawbuddy-prefix, separate directories, never touch existing Skills - Continuous iteration, no permanent bans: Failed task labels pause and wait for new evidence, never permanently abandoned
- User-controlled: All offload decisions confirmed by user, Dashboard allows viewing, editing, and rollback at any time
- Data safety: All data stored in local SQLite, nothing uploaded
| Command | Description |
|---|---|
clawbuddy start |
One-click start (auto-backup, inject proxy, launch services) |
clawbuddy stop |
Stop and restore OpenClaw config |
clawbuddy status |
View status |
clawbuddy config show |
Show current config |
clawbuddy config set <key> <value> |
Edit config (supports dot notation) |
clawbuddy offload enable <label> |
Enable offload for a task type |
clawbuddy offload disable <label> |
Disable offload |
clawbuddy offload list |
List offloaded task types |
clawbuddy export |
Export training data |
clawbuddy validate <label> |
Manually trigger validation |
- Language: TypeScript (ESM)
- HTTP Server: Hono + @hono/node-server
- Storage: SQLite (better-sqlite3)
- CLI: Commander.js
- Dashboard: HTML + Vanilla JS + Chart.js
- Bundler: tsdown
OpenClaw 的降本 buddy。让你的 AI 助手越用越便宜。
ClawBuddy 是 OpenClaw 的成本优化插件。它以透明代理的方式接管 OpenClaw 的 API 调用,在后台收集数据、验证小模型能力、自动生成 Skill——让你逐步把昂贵的大模型调用迁移到便宜的小模型上,而不牺牲任务完成质量。
用户 → OpenClaw → ClawBuddy proxy (:18790) → 主 API (glm-5-turbo)
↓
┌──────────────────────┐
│ 后台(异步) │
│ │
│ Mode 1: 数据收集 │
│ Mode 2: mock 验证 │ ← cheap model (qwen3.5:9b) + skills
└──────────────────────┘
ClawBuddy 在本地启动一个 OpenAI-compatible proxy server,修改 OpenClaw 配置将 API 请求指向它。对 OpenClaw 完全透明——它只看到一个普通的 model provider。
纯数据收集,零侵入。
- 所有请求照常转发给大模型,用户体验零变化
- 后台自动收集每个 request 的完整 input/output
- 将同一 session 的多次请求串联成完整的 task 链路
- 用小模型给每个 task 自动打标签(如「文件整理」「代码重构」)
- 导出为 JSONL / LLaMA-Factory 格式,拿去 fine-tune 你的专属小模型
适合:有 GPU 资源,想通过训练从根本上提升小模型能力的用户。
沙盒验证 + 自动生成 Skill,training-free 降本。
核心循环:
日常使用大模型 (glm-5-turbo) 完成任务
↓ 后台收集 task 链路
在 mock 沙盒中让小模型 (qwen3.5:9b) 执行同样的任务
↓ 大模型判定结果
pass → 积累通过记录
fail → 分析失败原因 → 自动生成 OpenClaw Skill → 带 Skill 重新验证
↓ 某类任务累计 N 个验证通过
Dashboard 通知 →「诗歌创作」已验证,建议切换到 cheap model
↓ 用户一键启用 offload
大模型只在三个低频点被调用:生成 mock 环境、判卷、生成 Skill。日常打标签等操作全部由小模型完成。
适合:没有 GPU 或不想训练模型,希望通过 prompt engineering 提升小模型的用户。
git clone https://github.com/haochen2115/clawbuddy.git
cd clawbuddy
npm install
npm run build
npm link # 全局注册 clawbuddy 命令一条命令启动,一条命令停止:
# 启动(自动备份 OpenClaw 配置、注入 proxy、启动服务)
clawbuddy start
# 停止(Ctrl+C 或另一个终端运行)
clawbuddy stop就这样。启动后正常使用 OpenClaw,一切照旧。打开 http://localhost:18791 查看 Dashboard。
start 会自动完成:
- 备份 OpenClaw 配置(首次启动时)
- 注入 proxy provider 到 OpenClaw(OpenClaw 热加载,无需重启)
- 启动 proxy server + dashboard
stop(或 Ctrl+C)会自动完成:
- 停止所有服务
- 精准还原 OpenClaw 配置(只移除 proxy 相关字段,不覆盖其他修改)
默认配置就能用,但你也可以通过启动参数调整:
# 指定模式(默认 mode2)
clawbuddy start --mode mode1
# 指定 cheap model
clawbuddy start --cheap-provider ollama --cheap-model qwen3.5:9b
# 或者修改配置文件
clawbuddy config set mode mode1
clawbuddy config set cheap_api.model qwen3.5:9b
clawbuddy config show# 导出全部
clawbuddy export --format jsonl --output ./training_data.jsonl
# 按任务类型筛选
clawbuddy export --label "文件整理" --output ./file_org.jsonl
# 导出为 LLaMA-Factory 格式
clawbuddy export --format llamafactory --output ./dataset/# 查看状态
clawbuddy status
# 启用 / 停用 offload
clawbuddy offload enable "诗歌创作"
clawbuddy offload disable "诗歌创作"
clawbuddy offload list本地 Web Dashboard http://localhost:18791,包含 6 个面板:
| 面板 | 功能 |
|---|---|
| 概览 | 模式、任务总数、最近验证记录 |
| 任务类型 | 标签列表、频次、阶段、手动触发验证 |
| 数据 | 训练数据统计、标签分布图表、导出 |
| 验证 | 每个标签的验证详情:通过/失败/原因 |
| Skills | 自动生成的 Skills 列表,可查看/删除 |
| 路由 | 控制哪些任务类型启用 offload |
一目了然地查看任务总数、请求量、任务类型数和已验证数量。底部展示最近的验证记录,包括 pass/fail 原因。
所有被自动分类的任务标签一览。可以看到每种任务的收集数量、当前阶段(collecting → validating → validated → offloaded)、验证通过/失败次数,并支持手动触发验证。
浏览所有收集到的训练数据。支持按标签、日期筛选,可直接预览用户消息和助手回复。底部的饼图展示标签分布。支持一键导出为 JSONL 或 LLaMA-Factory 格式。
详细的验证记录。每条记录展示:时间、任务类型、使用的 cheap model、验证结果(pass/fail/not_mockable),以及大模型给出的具体评判原因——比如"小模型未保持 Banana 人设的语气"或"小模型正确理解了任务意图"。
ClawBuddy 自动生成的 OpenClaw Skills 列表。当小模型在某类任务上反复失败时,大模型会分析失败模式并生成针对性的 SKILL.md,帮助小模型在下次执行时表现更好。
核心操作面板。查看每种任务当前的路由状态(🔵 primary / 🟢 cheap),验证通过率,并可一键「启用 Offload」将任务切换到 cheap model,或「停用 Offload」切回大模型。支持任意阶段手动切换。
ClawBuddy 配置文件位于 ~/.clawbuddy/config.json:
{
"mode": "mode2", // mode1 | mode2
"proxy": {
"port": 18790, // proxy 端口
"dashboard_port": 18791 // dashboard 端口
},
"primary_api": { // 主 API(自动从 OpenClaw 读取)
"provider": "zai",
"base_url": "https://open.bigmodel.cn/api/coding/paas/v4",
"api_key": "...",
"model": "glm-5-turbo"
},
"cheap_api": { // 便宜的小模型
"provider": "ollama",
"base_url": "http://localhost:11434/v1",
"api_key": "ollama",
"model": "qwen3.5:9b"
},
"validation": {
"min_tasks_to_start": 3, // 开始验证的最少 task 数
"certify_after_n_passes": 5, // 通过 N 次后认证
"schedule": "idle" // idle | manual
},
"skills": {
"auto_generate": true, // 自动生成 Skill
"trigger_after_n_failures": 3, // 失败 N 次后触发
"output_dir": "~/.openclaw/workspace/skills/"
}
}ClawBuddy 兼容任何 OpenAI-compatible API 的模型:
| Provider | 配置示例 | 说明 |
|---|---|---|
| Ollama | --cheap-provider ollama --cheap-model qwen3.5:9b |
本地运行,零成本 |
| Ollama (大) | --cheap-provider ollama --cheap-model qwen3.5:27b |
本地运行,效果更好 |
| vLLM | --cheap-base-url http://localhost:8000/v1 |
自建推理服务 |
| 智谱 AI | --cheap-base-url https://open.bigmodel.cn/api/... |
国产便宜 API |
| Gemini Flash | --cheap-base-url ... |
Google 便宜模型 |
导出的 JSONL 格式:
{"messages": [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}], "metadata": {"task_label": "诗歌创作", "session_id": "abc123", "model": "glm-5-turbo", "timestamp": "2026-03-17T10:00:00Z"}}- 对 OpenClaw 零侵入:只改配置中的 baseUrl,不修改任何 OpenClaw 源码
- 只新增不修改:生成的 Skill 以
clawbuddy-前缀命名,独立目录,不碰已有 Skill - 持续迭代,不判死刑:task_label 验证失败后暂停等待新证据,不永久放弃
- 用户可控:所有 offload 决策由用户确认,Dashboard 上可随时查看、编辑、回退
- 数据安全:所有数据存储在本地 SQLite,不上传任何内容
| 命令 | 说明 |
|---|---|
clawbuddy start |
一键启动(自动备份、注入 proxy、启服务) |
clawbuddy stop |
停止并还原 OpenClaw 配置 |
clawbuddy status |
查看状态 |
clawbuddy config show |
查看当前配置 |
clawbuddy config set <key> <value> |
修改配置(支持 dot notation) |
clawbuddy offload enable <label> |
启用 offload |
clawbuddy offload disable <label> |
停用 offload |
clawbuddy offload list |
查看已 offload 的任务 |
clawbuddy export |
导出训练数据 |
clawbuddy validate <label> |
手动触发验证 |
- 语言:TypeScript (ESM)
- HTTP Server:Hono + @hono/node-server
- 存储:SQLite (better-sqlite3)
- CLI:Commander.js
- Dashboard:HTML + Vanilla JS + Chart.js
- 构建:tsdown






{ "mode": "mode2", // mode1 | mode2 "proxy": { "port": 18790, // proxy port "dashboard_port": 18791 // dashboard port }, "primary_api": { // Primary API (auto-read from OpenClaw) "provider": "zai", "base_url": "https://open.bigmodel.cn/api/coding/paas/v4", "api_key": "...", "model": "glm-5-turbo" }, "cheap_api": { // Cheap small model "provider": "ollama", "base_url": "http://localhost:11434/v1", "api_key": "ollama", "model": "qwen3.5:9b" }, "validation": { "min_tasks_to_start": 3, // Min tasks to start validation "certify_after_n_passes": 5, // Certify after N passes "schedule": "idle" // idle | manual }, "skills": { "auto_generate": true, // Auto-generate Skills "trigger_after_n_failures": 3, // Trigger after N failures "output_dir": "~/.openclaw/workspace/skills/" } }