Command mode
When the user sends /diag command, directly execute the script without additional explanation:
| User input | Execute command | Description |
|---|---|---|
/diag |
-s |
Today's summary (default) |
/diag full |
(无-s) |
Full report (including Run details + error list) |
/diag full -l 3 |
-l 3 |
Full details of the most recent 3 Runs |
/diag -a waicode |
-s -a waicode |
Summary for the specified agent |
/diag -a main full |
-a main |
Full report for the specified agent |
/diag 2026-03-19 |
-s 2026-03-19 |
Summary for the specified date |
/diag errors |
(无-s) |
Execute full report, extracting only the error section for summary |
Rules:
- When no arguments, default to
-s(summary mode, most concise) fullkeyword → remove-s, output includes Run detailserrorskeyword → execute full report, extract only the error list-a、-l, date arguments are passed directly to the script- Remove ANSI color codes: pipe
| sed 's/\x1b\[[0-9;]*m//g' - Not supported
-f(real-time tracking); this mode must be run in an SSH terminal - Direct output mode: script output is sent directly to the user using the
messagetool as-is, without model summarization. Specific steps:- Execute the script, store stdout in a variable
- Use
message(action="send", message=output)to send the raw output - Then reply
NO_REPLY(to avoid duplicate sending) - If the output exceeds 4000 characters, send it in 4000-character segments (Telegram message length limit)
- Wrap each segment with ``` code block, maintaining monospaced font formatting
Natural language mode
When the user asks in natural language (such as "how is the running status" or "what did waicode do today"), choose appropriate parameters yourself to execute the script, and summarize the key information in Chinese.
Quick start
# 诊断今天的数据
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
Mode descriptions
| Mode | Arguments | Description |
|---|---|---|
| Summary statistics | -s(default) |
KPI overview, most concise |
| Full report | No -s |
Includes Run details + timeline + error list |
| Agent filter | -a <name> |
Only view the specified agent |
| Limit count | -l N |
Only show the most recent N Runs |
| Specify date | YYYY-MM-DD |
Defaults to today |
Arguments can be combined:-s -a main、-l 3 -a wairesearch。
Real-time tracking (
-f) and advanced mode (--advanced) must be run in an SSH terminal, see references/advanced-mode.md。
Data sources
The script has two data sources, switched automatically:
| Data source | Path | Requires configuration | Precision |
|---|---|---|---|
| Debug logs | /tmp/openclaw/openclaw-YYYY-MM-DD.log |
diagnostics.enabled: true |
Precise Run boundaries |
| Session files | ~/.openclaw/agents/*/sessions/*.jsonl |
No configuration required | Virtual Run (message timestamp estimation) |
Automatically downgrades to session mode when there are no debug logs; core metrics (inference time, Token, tool statistics) remain accurate.
Output content
Summary statistics
- Model call count, average inference latency, Token throughput
- Tool call count, success rate, total time
- Thinking statistics (count, average depth)
- Per-Agent activity distribution
Run details (non-summary mode)
- Timeline of each Run (inference segments + tool call segments)
- Inference time, output Token, throughput rate
- Tool call parameter summary
Error list
- Most recent 20 errors, in reverse chronological order
Usage guide
Daily checks
# 快速了解今天的运行概况
bash scripts/byted-openclaw-diag.sh -s
Performance troubleshooting
# 查看某天详细 Run 数据,找到慢查询
bash scripts/byted-openclaw-diag.sh 2026-03-19 -l 10
Specific Agent analysis
# 只看 waicode 的活动
bash scripts/byted-openclaw-diag.sh -a waicode -s
Real-time monitoring (SSH terminal)
# 需在 SSH 终端运行,不适合 Telegram/聊天
bash scripts/byted-openclaw-diag.sh -f
bash scripts/byted-openclaw-diag.sh -f --advanced
Notes
- The script depends on
python3(3.7+, usingdatetime.fromisoformat) andbash - Advanced mode (
--advanced) will temporarily modifyopenclaw.jsonand restart the Gateway, automatically restoring on exit - On machines without Swap, watch memory when running multiple Agents concurrently
- Timestamps are uniformly handled in UTC, unaffected by the local time zone