Token消耗监控优化

v1.2.0

AI Token消耗监控优化工具。读取会话日志,统计Token消耗,检测异常模式(短时激增、重复失败等),提供优化建议,生成消耗趋势报告。 中文优先,面向QClaw/OpenClaw用户。 当用户说"Token消耗"、"费用多少"、"Token统计"、"超支"、"优化建议"时触发。 Keywords: Token...

0· 124·0 current·0 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for freedompixels/qclaw-token-monitor.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Token消耗监控优化" (freedompixels/qclaw-token-monitor) from ClawHub.
Skill page: https://clawhub.ai/freedompixels/qclaw-token-monitor
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install qclaw-token-monitor

ClawHub CLI

Package manager switcher

npx clawhub@latest install qclaw-token-monitor
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
medium confidence
Purpose & Capability
The name/description (token consumption monitoring and optimization) aligns with the actions described (reading session logs under ~/.qclaw/agents/main/sessions/*.jsonl and running a token_stats.py script). However the skill is instruction-only and does not include the referenced scripts; it therefore depends on those local files being present on the user's machine.
Instruction Scope
SKILL.md explicitly instructs the agent to run local Python scripts and to read session log files in ~/.qclaw/agents/main/sessions/*.jsonl and write stats to memory/token-usage-YYYY-MM-DD.json. Reading session logs is required for token accounting; the scope does not attempt to exfiltrate data or call external endpoints in the instructions.
Install Mechanism
There is no install spec and no code shipped with the skill (instruction-only). This minimizes installation risk, but also means functionality depends entirely on pre-existing local scripts at the documented paths.
Credentials
The skill requests no environment variables, credentials, or external config paths. It only references local session logs and local script paths which are coherent with its stated purpose.
Persistence & Privilege
always is false and the skill does not request elevated/persistent platform privileges. It does read user session files and write local stats, which is appropriate for its purpose.
Assessment
This skill is instruction-only and expects Python scripts at ~/.qclaw/skills/token-monitor/scripts/token_stats.py and session logs at ~/.qclaw/agents/main/sessions/*.jsonl. Before using: (1) Confirm those script files actually exist and inspect their contents — do not run unknown scripts without review. (2) Be aware session logs may contain message text, PII, or API keys; ensure you are comfortable the tool will only compute token metrics and will not transmit sensitive data. (3) Check file permissions and backups for any files the scripts will write (memory/token-usage-*.json). (4) If the scripts require third-party Python packages (despite the SKILL.md saying none), review and vet those dependencies. If you cannot review the local scripts, consider declining or asking the skill author for the implementation before installation.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

📊 Clawdis
latestvk977rzwcp059g3kp8wf85q8r8h84t0qx
124downloads
0stars
3versions
Updated 1w ago
v1.2.0
MIT-0

Token消耗监控优化

监控 AI Token 消耗,检测异常,提供优化建议。

功能

  • 📊 读取 session 日志统计 Token 消耗
  • 🚨 检测异常消耗(短时激增、重复失败等)
  • 💡 给出优化建议
  • 📈 生成消耗趋势报告

使用

检查今日消耗

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --today

检查指定日期

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --date 2026-04-14

检查异常模式

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --check-anomaly

生成优化报告

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --report

异常检测规则

规则阈值说明
单日总量>1000万严重超标
单小时>200万需要检查
重复失败>3次死循环风险
浏览器快照单次>5000字未压缩

历史数据参考

日期InputOutputTotal状态
4/113.46M117K28.8M🚨 超标
4/125.57M127K37.0M🚨 严重超标
4/131.80M22K9.5M⚠️ 偏高
4/14430K20K3.7M✅ 正常

4/12是Token浪费最严重的一天:3700万token,根因是Chrome CDP崩溃重试+ClawHub限速重试

优化建议库

  • 浏览器快照用 compact=true
  • 同一操作失败3次立即换方案
  • 限速不硬等,跳转做其他事
  • 后台进程不轮询
  • Context超过150K时触发LCM压缩

数据存储

  • 日志:~/.qclaw/agents/main/sessions/*.jsonl
  • 统计:memory/token-usage-YYYY-MM-DD.json

依赖

  • Python 3(系统自带)
  • 无第三方依赖

Comments

Loading comments...