OpenClaw usage and performance reporting. Parse session JSONL to answer how long each agent task took, which tools/skills/models were used, and how many tokens were consumed — zero dependency, local only, no cost dimension (token is the primary metric). Read-only: never modifies any file, aggregates statistics only, never leaks conversation content. Use when the user asks about token usage, task duration, slowest tools, skill usage, or per-agent consumption (今天花了多少 token/哪个工具最慢/ 任务耗时/用量报告), or scheduled via cron. 中文:OpenClaw 用量与性能查询。 解析 session JSONL,回答每次 agent 任务耗时、所用工具/技能/模型、token 消耗。零依赖纯本地,不提供成本维度(token 为主指标)。只读:不修改任何 文件,只输出聚合统计,不泄露会话内容。用户问 token 用量、任务耗时、 最慢工具、技能使用、按 agent 消耗时使用。cron 每日日报为可选项,用户 自行设置。
文档
token-usage
试用Track, aggregate, and report OpenClaw token usage and costs across sessions.
它能做什么
Track, aggregate, and report OpenClaw token usage and costs across sessions.
技能文档
Token Usage Tracker
Parse OpenClaw and Codex session JSONL files to extract token usage, aggregate by date/model/session, and generate cost reports across providers.
When to Use
- User asks "how many tokens did I use today/this week"
- User wants to know session costs or model breakdown
- Budget monitoring and anomaly detection
- Before/after optimization comparisons
Workflow
- Locate sessions — Find
.jsonlfiles in OpenClaw agent sessions and nested Codex rollout sessions - Parse usage — Extract OpenClaw message usage or Codex
event_msg/token_countper-turn usage - Aggregate — Group by date, model, session ID
- Report — Output summaries, trends, cost estimates
Commands
Parse and aggregate current sessions (OpenClaw + Codex)
python3 ~/.openclaw/skills/token-usage/scripts/parse.py --today
Weekly report with cost estimates
python3 ~/.openclaw/skills/token-usage/scripts/parse.py --week --costs
Report by cron job (daily breakdown per job)
python3 ~/.openclaw/skills/token-usage/scripts/parse.py --week --by-cron
Weekly cron report with costs (JSON output)
python3 ~/.openclaw/skills/token-usage/scripts/parse.py --week --by-cron --costs --json
All-time summary by model
python3 ~/.openclaw/skills/token-usage/scripts/parse.py --all --by-model
Export to JSON for external dashboards
python3 ~/.openclaw/skills/token-usage/scripts/parse.py --week --json > /tmp/token-report.json
Data Format
Sessions are stored as JSONL with lines like:
{"type":"message","message":{"role":"assistant",...},"usage":{"input":1000,"output":500,"totalTokens":1500},...}
Cost Estimation
Uses model pricing from scripts/pricing.json (user-editable). The bundled table includes Kimi, OpenAI/GPT, Anthropic/Claude, and OpenRouter models. Unknown models are reported without a cost estimate rather than silently priced as Kimi.
Default examples (USD per 1M tokens):
- Kimi k2.7: $0.50/1M input, $2.00/1M output
- Claude Sonnet 4: $3.00/1M input, $15.00/1M output
- GPT-4o: $2.50/1M input, $10.00/1M output
Costs are approximate. Cache read/write pricing applied when available.
Important: What "Total" Means
The script reports input + output tokens as the usage metric. This is the actual new token consumption per turn.
The totalTokens field in session files includes cacheRead (cached context window), which gets re-counted at every turn. Summing totalTokens across messages would massively overcount — a 10K context used for 100 turns would appear as 1M tokens. The script avoids this by only summing input and output.
Output Locations
- Daily summaries:
~/.openclaw/skills/token-usage/logs/YYYY-MM-DD.md - Weekly reports:
~/.openclaw/skills/token-usage/logs/week-YYYY-Www.md - Raw JSON exports: user-specified or
/tmp/token-usage-*.json
Limitations
- OpenClaw records are parsed from
message.usage; Codex rollouts are parsed frompayload.info.last_token_usageintoken_countevents input + outputis the new-usage metric; Codex cached input is reported separately ascacheRead- Historical sessions before JSONL format are not supported
- Costs are estimates; actual billing may differ
相关技能
为 OpenClaw 代理减少重复性的 token 消耗:按需加载上下文、Sonnet/Opus 分流、缓存感知的 heartbeat 调度。
把 OpenClaw 每次模型调用的 token 用量与费用落到 SQLite 的审计型账本。
Track every token and dollar your OpenClaw agent spends, set budget walls that actually refuse calls, and replay runs on free local models. Local-first: all data stays on this machine. Use when the user asks about cost, spend, tokens, budgets, usage reports, or what the agent has been doing.
按命令族和 profile 选择合适的 OpenClaw CLI 命令,并校验执行结果。
通过多轮引导式问答,生成完整的 OpenClaw 个人 AI 助手配置文件。