
Byted Openclaw Diag
- 30 installs
- 411 repo stars
- Updated August 4, 2026
- bytedance/agentkit-samples
byted-openclaw-diag is a skill that analyzes OpenClaw agent performance, reporting inference latency, token usage, tool-call statistics, run timelines, and errors.
About
byted-openclaw-diag is a diagnostics and performance-analysis tool for OpenClaw agents. It reports model call counts, average inference latency, token throughput, tool-call statistics, per-run timelines, and recent errors. A developer runs it to check an agent's daily run status, find performance bottlenecks, or investigate errors, with a /diag command and modes for summary, full report, per-agent filtering, and live tracking.
- Analyzes OpenClaw agent inference latency, token usage, and tool-call statistics
- Modes for batch analysis, live tracking (-f), summary stats (-s), and advanced diagnostics
- Reads debug logs or session files, degrading gracefully when debug logs are absent
Byted Openclaw Diag by the numbers
- 30 all-time installs (skills.sh)
- Ranked #359 of 596 Debugging skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
byted-openclaw-diag capabilities & compatibility
Free; runs locally against OpenClaw log and session files with python3 and bash.
- Capabilities
- performance analysis · agent diagnostics · error analysis
- Use cases
- debugging
- Runs
- Runs locally
- Pricing
- Free
What byted-openclaw-diag says it does
无 debug 日志时自动降级为 session 模式,核心指标(推理耗时、Token、工具统计)仍然准确。
脚本依赖 `python3`(3.7+,使用 `datetime.fromisoformat`)和 `bash`
- 模型调用次数、平均推理延迟、Token 吞吐量
npx skills add https://github.com/bytedance/agentkit-samples --skill byted-openclaw-diagAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 30 |
|---|---|
| repo stars | ★ 411 |
| Last updated | August 4, 2026 |
| Repository | bytedance/agentkit-samples ↗ |
What it does
Diagnose OpenClaw agent performance by reporting inference latency, token usage, tool-call stats, and recent errors.
Who is it for?
Investigating OpenClaw agent latency, token consumption, tool-call stats, and errors.
Skip if: Diagnosing non-OpenClaw runtimes, since it parses OpenClaw debug logs and session files.
When should I use this skill?
The user asks about OpenClaw run status, performance bottlenecks, inference latency, token consumption, or errors.
What you get
Produces a summary or full diagnostic report of agent runs, latency, throughput, and recent errors.
- A summary of model calls, inference latency, and token throughput
- Per-run timelines and a recent error list
By the numbers
- Lists the most recent 20 errors in reverse chronological order
- 2 data sources (debug log, session file)
Files
OpenClaw 诊断工具
指令模式
当用户发送 /diag 指令时,直接执行脚本,不做额外解释:
| 用户输入 | 执行命令 | 说明 |
|---|---|---|
/diag | -s | 今日摘要(默认) |
/diag full | (无-s) | 完整报告(含 Run 详情 + 错误列表) |
/diag full -l 3 | -l 3 | 最近 3 个 Run 完整详情 |
/diag -a waicode | -s -a waicode | 指定 agent 摘要 |
/diag -a main full | -a main | 指定 agent 完整报告 |
/diag 2026-03-19 | -s 2026-03-19 | 指定日期摘要 |
/diag errors | (无-s) | 执行完整报告,只提取错误部分汇总 |
规则: 1. 无参数时默认 -s(摘要模式,最简洁) 2. full 关键词 → 去掉 -s,输出含 Run 详情 3. errors 关键词 → 执行完整报告,只摘出错误列表 4. -a、-l、日期参数直接透传给脚本 5. 去除 ANSI 颜色码:管道 | sed 's/\x1b\[[0-9;]*m//g' 6. 不支持 -f(实时跟踪),该模式需在 SSH 终端运行 7. 直出模式:脚本输出直接用 message 工具原样发送给用户,不经过模型总结。 具体做法:
- 执行脚本,将 stdout 存入变量
- 用
message(action="send", message=output)发送原始输出 - 然后回复
NO_REPLY(避免重复发送) - 如果输出超过 4000 字符,按 4000 字符分段发送(Telegram 消息长度限制)
- 每段用 ``` 代码块包裹,保持等宽字体排版
自然语言模式
当用户用自然语言询问(如"运行状态怎么样"、"waicode今天干了啥")时, 自行选择合适参数执行脚本,并用中文汇总关键信息。
快速使用
# 诊断今天的数据
bash scripts/byted-openclaw-diag.sh
# 诊断指定日期
bash scripts/byted-openclaw-diag.sh 2026-03-19
# 只看摘要
bash scripts/byted-openclaw-diag.sh -s
# 实时跟踪(类似 tail -f)
bash scripts/byted-openclaw-diag.sh -f
# 高级实时跟踪(自动开启 debug 日志,退出时恢复)
bash scripts/byted-openclaw-diag.sh -f --advanced
# 只看指定 agent
bash scripts/byted-openclaw-diag.sh -a waicode
# 最近 5 个 Run
bash scripts/byted-openclaw-diag.sh -l 5模式说明
| 模式 | 参数 | 说明 |
|---|---|---|
| 摘要统计 | -s(默认) | KPI 概览,最简洁 |
| 完整报告 | 无 -s | 含 Run 详情 + 时间线 + 错误列表 |
| Agent 过滤 | -a <name> | 只看指定 agent |
| 限制数量 | -l N | 只显示最近 N 个 Run |
| 指定日期 | YYYY-MM-DD | 默认今天 |
参数可组合:-s -a main、-l 3 -a wairesearch。
实时跟踪(-f)和高级模式(--advanced)需在 SSH 终端运行,
详见 references/advanced-mode.md。
数据源
脚本有两种数据源,自动切换:
| 数据源 | 路径 | 需要配置 | 精度 |
|---|---|---|---|
| Debug 日志 | /tmp/openclaw/openclaw-YYYY-MM-DD.log | diagnostics.enabled: true | 精确 Run 边界 |
| Session 文件 | ~/.openclaw/agents/*/sessions/*.jsonl | 无需配置 | 虚拟 Run(消息时间戳推算) |
无 debug 日志时自动降级为 session 模式,核心指标(推理耗时、Token、工具统计)仍然准确。
输出内容
摘要统计
- 模型调用次数、平均推理延迟、Token 吞吐量
- 工具调用次数、成功率、总耗时
- Thinking 统计(次数、平均深度)
- Per-Agent 活动分布
Run 详情(非摘要模式)
- 每个 Run 的时间线(推理段 + 工具调用段)
- 推理耗时、输出 Token、吞吐速率
- 工具调用参数摘要
错误列表
- 最近 20 条错误,按时间倒序
使用指南
日常检查
# 快速了解今天的运行概况
bash scripts/byted-openclaw-diag.sh -s性能排查
# 查看某天详细 Run 数据,找到慢查询
bash scripts/byted-openclaw-diag.sh 2026-03-19 -l 10特定 Agent 分析
# 只看 waicode 的活动
bash scripts/byted-openclaw-diag.sh -a waicode -s实时监控(SSH 终端)
# 需在 SSH 终端运行,不适合 Telegram/聊天
bash scripts/byted-openclaw-diag.sh -f
bash scripts/byted-openclaw-diag.sh -f --advanced注意事项
- 脚本依赖
python3(3.7+,使用datetime.fromisoformat)和bash - 高级模式(
--advanced)会临时修改openclaw.json并重启 Gateway,退出时自动恢复 - 无 Swap 的机器上并发多 Agent 时注意内存
- 时间戳统一为 UTC 处理,不受本地时区影响
高级模式参考
高级模式工作原理
--advanced 仅在实时跟踪模式 (-f) 下生效:
1. 检查 openclaw.json 中 diagnostics.enabled 和 logLevel 配置 2. 如果未开启,备份配置文件,修改为 diagnostics.enabled: true + logLevel: debug 3. 自动重启 Gateway(等待最多 60 秒) 4. 开始实时跟踪 5. Ctrl+C 退出时提示是否恢复原配置
配置项
| 配置 | 作用 | 高级模式设置 |
|---|---|---|
diagnostics.enabled | 启用 Run 事件记录 | true |
logLevel | 日志详细度 | debug |
手动开启(不用 --advanced)
openclaw config set diagnostics.enabled true
openclaw config set logLevel debug
openclaw gateway restartSession 文件结构
路径:~/.openclaw/agents/{agent}/sessions/{id}.jsonl
每行一个 JSON 对象,关键字段:
role: user / assistant / toolCall / toolResult / custom_messagetimestamp: ISO 8601 UTCmodel: 模型名称usage:{input, output, cacheRead, cacheWrite, totalTokens}toolResult.details:{exitCode, durationMs, stdout, stderr}
虚拟 Run 构造算法
当无 debug 日志时: 1. 扫描所有 agent 的 session 文件(含 .reset. 和 .deleted.) 2. 按日期过滤消息(UTC ±1 天容错) 3. 每条 user 消息标记为 Run 起点 4. 到下一条 user 消息或文件末尾为 Run 终点 5. 聚合 Run 内的 assistant/toolCall/toolResult 统计
多 Agent 支持
脚本扫描 ~/.openclaw/agents/*/sessions/ 下所有 agent。
-a <name> 过滤逻辑:
- 批量模式:通过 session 文件路径提取 agent 名称,过滤 Run
- 实时跟踪:从日志中
sessionKey=agent:{name}:{id}提取 agent,过滤事件
Related skills
FAQ
What data sources does byted-openclaw-diag use?
It reads OpenClaw debug logs for precise run boundaries, or falls back to session files, keeping core metrics accurate.
Does it support live tracking?
Yes, the -f live-tracking and --advanced modes run in an SSH terminal, not in a chat channel.