简介
Clawsaver
原始描述
Reduce model API costs by 20–40% through intelligent message batching. Buffer related messages, send once.
通过你的 Agent 添加
安装目录:clawsaver/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: clawsaver
description: Reduce model API costs by 20–40% through intelligent message batching. Buffer related messages, send once.
metadata:
clawdbot:
emoji: "⚡"
requires:
env: []
bins: []
files: ["SessionDebouncer.js", "example-integration.js"]
ClawSaver
Reduce model API costs by 20–40% through intelligent message batching and buffering.
Most agent systems waste money on redundant API calls. When users send follow-up messages, you call the model separately for each one. ClawSaver fixes this by waiting ~800ms to collect related messages, then sending them together in a single optimized request. Same response quality. Lower cost. No user friction.
How It Works: Batching & Buffering
WITHOUT CLAWSAVER:
User: "What is ML?"
Model: → API Call #1 (cost: $X)
User: "Give an example"
Model: → API Call #2 (cost: $X)
User: "Apply to finance?"
Model: → API Call #3 (cost: $X)
Total cost: 3X, three fragmented responses
───────────────────────────────────────
WITH CLAWSAVER (Batching + Buffering):
User: "What is ML?" ← Buffer (800ms wait)
User: "Give an example" ← Buffer (800ms wait)
User: "Apply to finance?" ← Flush: Send all 3 together
Model: → API Call #1 (cost: $X) [receives all 3 questions]
→ Returns comprehensive answer addressing all three
Total cost: 1X, three coherent insights in one response
Savings: 67% reduction in API calls
WITHOUT CLAWSAVER:
User: "What is ML?"
Model: → API Call #1 (cost: $X)
User: "Give an example"
Model: → API Call #2 (cost: $X)
User: "Apply to finance?"
Model: → API Call #3 (cost: $X)
Total cost: 3X, three fragmented responses
───────────────────────────────────────
WITH CLAWSAVER (Batching + Buffering):
User: "What is ML?" ← Buffer (800ms wait)
User: "Give an example" ← Buffer (800ms wait)
User: "Apply to finance?" ← Flush: Send all 3 together
Model: → API Call #1 (cost: $X) [receives all 3 questions]
→ Returns comprehensive answer addressing all three
Total cost: 1X, three coherent insights in one response
Savings: 67% reduction in API calls
Key insight: Users are already waiting for your model to respond. Buffering input doesn't add perceived latency—it happens during the response time they expect anyway.
The Problem
User: "What is machine learning?"
(pause)
User: "Give an example"
(pause)
User: "How does that apply to healthcare?"
User: "What is machine learning?"
(pause)
User: "Give an example"
(pause)
User: "How does that apply to healthcare?"
Without optimization: 3 API calls = 3x cost
With ClawSaver: 1 batched call = 1/3 the price
Across thousands of conversations, this compounds fast.
How It Works
- User sends message → ClawSaver buffers it
- Waits ~800ms for follow-ups from same user
- If more messages arrive → keep buffering
- Timer expires → send all messages together
- Model responds once → you get complete answer
Why users don't notice: They're already waiting for your model response. Buffering input doesn't feel slower because the response comes right after the batch sends.
Install
clawhub install clawsaver
Quick Start (10 lines)
import SessionDebouncer from 'clawsaver';
const debouncers = new Map();
function handleMessage(userId, text) {
if (!debouncers.has(userId)) {
debouncers.set(userId, new SessionDebouncer(
userId,
(msgs) => callModel(userId, msgs)
));
}
debouncers.get(userId).enqueue({ text });
}
Impact
Metric
Value
Cost reduction
20–40% typical
Setup time
10 minutes
Code added
~10 lines
Dependencies
0
File size
4.2 KB
Latency added
+800ms (user-imperceptible)
Maintenance
None
Three Profiles
clawhub install clawsaver
import SessionDebouncer from 'clawsaver';
const debouncers = new Map();
function handleMessage(userId, text) {
if (!debouncers.has(userId)) {
debouncers.set(userId, new SessionDebouncer(
userId,
(msgs) => callModel(userId, msgs)
));
}
debouncers.get(userId).enqueue({ text });
}
Impact
Metric
Value
Cost reduction
20–40% typical
Setup time
10 minutes
Code added
~10 lines
Dependencies
0
File size
4.2 KB
Latency added
+800ms (user-imperceptible)
Maintenance
None
Three Profiles
| Metric | Value |
|---|---|
| Cost reduction | 20–40% typical |
| Setup time | 10 minutes |
| Code added | ~10 lines |
| Dependencies | 0 |
| File size | 4.2 KB |
| Latency added | +800ms (user-imperceptible) |
| Maintenance | None |
Choose based on your use case:
Balanced (Default)
- 25–35% savings
- 800ms buffer
- Chat, Q&A, general conversation
Aggressive
- 35–45% savings
- 1.5s buffer
- Batch workflows, high-volume ingestion
Real-Time
- 5–10% savings
- 200ms buffer
- Interactive, voice-first systems
When to Use
- 35–45% savings
- 1.5s buffer
- Batch workflows, high-volume ingestion
Real-Time
- 5–10% savings
- 200ms buffer
- Interactive, voice-first systems
When to Use
✅ Chat applications
✅ Customer support bots
✅ Multi-turn Q&A
✅ Any conversation with follow-ups
❌ Single-request workflows
❌ Sub-100ms response requirements
API
new SessionDebouncer(userId, handler, {
debounceMs: 800, // wait time
maxWaitMs: 3000, // absolute max
maxMessages: 5, // batch size cap
maxTokens: 2048 // reserved
})
// Methods
debouncer.enqueue(message) // add to batch
debouncer.forceFlush(reason) // send now
debouncer.getState() // buffer + metrics
debouncer.getStatusString() // human-readable
Docs
- START_HERE.md — Navigation (pick your role/timeline)
- AUTO-INTEGRATION.md — ⭐ Drop-in middleware wrapper (2 min setup)
- QUICKSTART.md — 5-minute integration
- INTEGRATION.md — Patterns, edge cases, full config
- SUMMARY.md — Metrics and ROI (decision makers)
- SKILL.md — Full API reference
- example-integration.js — Copy-paste templates
Security
- No telemetry — Doesn't phone home
- No network calls — Runs locally
- No dependencies — Pure JavaScript
- You control output — You decide what goes to your model
new SessionDebouncer(userId, handler, {
debounceMs: 800, // wait time
maxWaitMs: 3000, // absolute max
maxMessages: 5, // batch size cap
maxTokens: 2048 // reserved
})
// Methods
debouncer.enqueue(message) // add to batch
debouncer.forceFlush(reason) // send now
debouncer.getState() // buffer + metrics
debouncer.getStatusString() // human-readable
- START_HERE.md — Navigation (pick your role/timeline)
- AUTO-INTEGRATION.md — ⭐ Drop-in middleware wrapper (2 min setup)
- QUICKSTART.md — 5-minute integration
- INTEGRATION.md — Patterns, edge cases, full config
- SUMMARY.md — Metrics and ROI (decision makers)
- SKILL.md — Full API reference
- example-integration.js — Copy-paste templates
Security
- No telemetry — Doesn't phone home
- No network calls — Runs locally
- No dependencies — Pure JavaScript
- You control output — You decide what goes to your model
Data never leaves your machine.
License
MIT
Start here: Pick your path in START_HERE.md, or jump to QUICKSTART.md for 5-minute setup.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。