Track, aggregate, and report OpenClaw token usage and costs across sessions.
文档
OpenClaw Usage Report
试用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 每日日报为可选项,用户 自行设置。
它能做什么
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 每日日报为可选项,用户 自行设置。
技能文档
OpenClaw Usage Report
OpenClaw 用量与性能查询工具:读取本地 session JSONL(state/agents/*/sessions/*.jsonl),
输出任务耗时、工具耗时、模型 token/耗时、skills 使用、每日趋势。
零依赖(纯 Python 标准库)、纯本地、无外部服务、无成本维度(token 为主指标)。
触发场景
- 「今天花了多少 token」「哪个工具最慢」「哪个 agent 用 token 最多」
- 「每次任务花了多久」「用了哪些技能」
- 优化应用前的用量基线分析
用法
python /xiaoyaoclaw-usage-report/scripts/usage-report.py --today # 今日(默认全维度)
python /xiaoyaoclaw-usage-report/scripts/usage-report.py --week # 近 7 天
python /xiaoyaoclaw-usage-report/scripts/usage-report.py --all # 全部
python /xiaoyaoclaw-usage-report/scripts/usage-report.py --agent # 按 agent 过滤
python /xiaoyaoclaw-usage-report/scripts/usage-report.py --by-tool # 仅工具耗时
python /xiaoyaoclaw-usage-report/scripts/usage-report.py --skills # 仅技能使用
python /xiaoyaoclaw-usage-report/scripts/usage-report.py --today --json # JSON 输出
数据目录自动检测(Windows 小遥Claw:C:\Users\\AppData\Roaming\xiaoyaoclaw-desktop\runtime\openclaw\state);覆盖用 --state <路径> 或环境变量 OPENCLAW_STATE。
输出维度
- 总览:任务数、总 token(input+output)、总耗时
- 按 agent/模型:调用次数、输入/输出 token、模型总耗时/平均(近似)
- 按工具:次数、失败数、总耗时、平均、最慢
- Skills 使用:技能名、读取次数、使用 agent
- 任务排行:按活跃耗时(排除用户思考间隔)
- 每日趋势:每日输入/输出 token、调用数
统计口径(务必遵守)
- token 真实消耗 = input + output(totalTokens 含 cacheRead 会重复计数,禁用;实测虚高 1.3x~14x+)
- 工具耗时 = toolResult.ts − assistant(toolCall).ts(含模型决策时间)
- 模型耗时 = 近似估算(事件顶层 ts 间隔,cap 10min;⚠️ 不能用 message.timestamp,那是批量写入时间戳;精确值在 diagnostics-otel 事件层)
- 无成本维度:各供应商定价不同,token 是通用主指标
- skills 仅统计被 read 加载过的(metadata 注入不计)
Cron 每日日报(可选项,用户自行设置)
工具支持 --today --json,可挂定时任务生成日报。是否启用由使用者决定:
- OpenClaw cron:
agentTurn跑脚本 +delivery.announce推送(示例见 README.md) - 或 Windows 计划任务 / Linux crontab 直接执行脚本输出到文件
限制
- 活跃耗时为近似值(间隔 <5min 累计,可能含 heartbeat)
- 仅支持 JSONL version 3 会话
- 仅统计本机数据
环境要求
- Python 3.8+(标准库,零依赖)
- 可读 OpenClaw state 目录
姊妹项目
与 xiaoyaoclaw-workspace-initializer(家/规范)、xiaoyaoclaw-memory-distill(内容/记忆)、 xiaoyaoclaw-task-progress-tracker(状态/进度)、xiaoyaoclaw-kb-retriever(知识/检索)、 xiaoyaoclaw-workspace-auditor(健康/体检)、xiaoyaoclaw-web-clipper(输入/剪藏)、 xiaoyaoclaw-agent-orchestrator(协作/编排)组成小遥生态工具链。
相关技能
OpenClaw multi-agent daily collaboration orchestrator: split a task into subtasks, dispatch to resident agents via sessions_send, track progress via sessions_list/sessions_history, aggregate results with source attribution, and retry failures (default max 3). Reads openclaw.json for agents.list and agentToAgent.allow (bidirectional whitelist); three-tier trigger (explicit dispatch / suggest+ask for fuzzy big tasks / silent otherwise). Use when user asks to orchestrate/coordinate multiple agents, dispatch parallel work, delegate to a named agent, or aggregate results from several agents (orchestrate/parallel/delegate/让 XX 做/编排/并行/ 分给/汇总). 中文:OpenClaw 多 Agent 日常协作编排器——任务拆解、跨 agent 分发(强制 sessions_send)、进度追踪、结果聚合、失败重试(默认最多 3 次)。 三档触发:用户点名或含编排动词直接执行;模糊大任务建议并行并询问用户; 其余情况保持沉默。直接读 openclaw.json(agents.list + agentToAgent.allow 双向白名单)获取 agent 名单与授权。适用于多 agent 家庭协作、并行调研、批量巡检、发布前多视角审查、团队日报汇总等场景。
Drive OpenClaw with Claude Code, Codex, OpenCode, Trae, DSH etc. — command the gateway, its agents and channels, from any Agent Skills tool. Use when you want other AI tools to make OpenClaw work. 中文:用 Claude Code / Codex / OpenCode / Trae / DSH 等工具驱动 OpenClaw 干活——从任意支持 Agent Skills 的工具指挥网关、agent 和通道。 当你想用其他 AI 工具驱动 OpenClaw 时使用。
OpenClaw task & project progress tracking. Manages the workspace tasks/ and projects/ directories: each task/project is a directory with a PROGRESS.md card (status + progress log + document index). Covers the full lifecycle: create, update progress, index documents,review, complete.
OpenClaw local knowledge-base retriever: hierarchical data_structure.md index navigation + progressive retrieval, zero external dependencies, Windows & macOS. Use when user asks to retrieve/answer from a knowledge base directory (knowledge base/retrieve/ RAG over local files). 面向本地知识库目录的检索和问答助手。
Audit an OpenClaw agent workspace and generate standardized evaluation reports, scores, and patches. Use when asked to review memory quality, retrieval effic...