← 返回
未分类 中文

Clawdoc

Diagnose OpenClaw agent failures, cost spikes, and performance issues with 14 pattern detectors. Use when: task failed unexpectedly, costs seem high, agent b...
使用14种模式检测器诊断OpenClaw智能体故障、成本激增和性能问题。适用场景:任务意外失败、成本异常偏高、智能体行为异常等。
ashishjaingithub ashishjaingithub 来源
未分类 clawhub v0.12.0 1 版本 99794.2 Key: 无需
★ 0
Stars
📥 485
下载
💾 1
安装
1
版本
#agent-health#cost-optimization#debugging#diagnostics#latest#observability

概述

clawdoc

Examine agent sessions. Diagnose failures. Prescribe fixes.

Invocation modes

/clawdoc (slash command — default: headline mode)

Produces a compact, tweetable health check:

🩻 clawdoc — 3 findings across 12 sessions (last 7 days)
💸 $47.20 spent — $31.60 was waste (67% recoverable)
🔴 Retry loop on exec burned $18.40 in one session
🟡 Opus running 34 heartbeats ($8.20 → $0.12 on Haiku)
🟡 SOUL.md is 9,200 tokens — 14% of your context window

Run: bash {baseDir}/scripts/headline.sh ~/.openclaw/agents/main/sessions

/clawdoc full or "give me a full diagnosis"

Runs all 14 pattern detectors and produces the complete diagnosis report with evidence and prescriptions.

/clawdoc brief or "clawdoc one-liner for daily brief"

Single-line summary for morning cron integration:

Yesterday: 8 sessions, $3.40, 1 warning (cron context growth on daily-report)

Run: bash {baseDir}/scripts/headline.sh --brief ~/.openclaw/agents/main/sessions

Natural language triggers

Also activates when user says: "what went wrong", "why did that fail", "debug", "diagnose", "why was that so expensive", "where are my tokens going", "cost breakdown", "health check", "check my agent", "what's wrong", "examine"

Quick examination — most recent session

Find the most recent session file and run:

bash {baseDir}/scripts/examine.sh <session.jsonl>

This outputs a JSON summary with turns, cost, token counts, tool call frequency, and error count.

Single-session diagnosis

Run all 14 pattern detectors against a specific session file:

bash {baseDir}/scripts/diagnose.sh <session.jsonl> | jq .

Diagnosis with prescriptions

Pipe diagnose output into prescribe for a formatted report with fix recommendations:

bash {baseDir}/scripts/diagnose.sh <session.jsonl> | bash {baseDir}/scripts/prescribe.sh

Cost breakdown

Show per-turn cost waterfall for a session:

bash {baseDir}/scripts/cost-waterfall.sh <session.jsonl> | jq '.[0:5]'

Cross-session pattern recurrence

Analyze pattern recurrence across multiple sessions in a directory:

bash {baseDir}/scripts/history.sh <sessions-dir> | jq .

Full diagnosis

When the user wants a comprehensive diagnosis, run the scripts above and synthesize findings into this report format:

Diagnosis report format

## 🩻 Diagnosis — [date]

### Patient summary
- Sessions examined: N
- Period: [date range]
- Total spend: $X.XX
- Total tokens: XXk in / XXk out

### Findings

#### 🔴 Critical
[Infinite retry loops, context exhaustion, tool-as-text failures]
Each finding includes: what happened, evidence, estimated cost impact, and specific prescription.

#### 🟡 Warning
[Cost spikes, model routing waste, cron accumulation, compaction damage, workspace overhead]

#### 🟢 Healthy
[What's working well — efficient sessions, good model routing]

### Prescriptions (ranked by cost impact)
1. [Highest-impact fix with specific config change or command]
2. [Second highest]
3. [Third]

### Cost breakdown
[Per-day costs for the examination period]
[Top 3 most expensive sessions with root cause]

Pattern reference

#PatternSeverityKey indicator
------------------------------------
1Infinite retry loop🔴 CriticalSame tool called 5+ times consecutively
2Non-retryable error retried🔴 HighValidation error → identical retry
3Tool calls as text🔴 HighTool names in assistant text, no toolCall blocks
4Context window exhaustion🟡-🔴inputTokens > 70% of contextTokens
5Sub-agent replay🟡 MediumDuplicate completion messages in parent
6Cost spike🟡-🔴Session cost > 2x rolling average
7Skill selection miss🟢 Low"command not found" after skill activation
8Model routing waste🟡 MediumPremium model on heartbeat/cron
9Cron context accumulation🟡 MediumGrowing inputTokens across cron runs
10Compaction damage🟡 MediumPost-compaction tool call repetition
11Workspace token overhead🟡 MediumBaseline > 15% of context window
12Task drift🟡 MediumPost-compaction directory divergence or 10+ reads without edits
13Unbounded walk🟠 HighRepeated unscoped find/grep -r flooding output
14Tool misuse🟡 MediumSame file read 3+ times without edit, or identical search repeated

Self-improving-agent integration

To enable writing findings to .learnings/LEARNINGS.md, set CLAWDOC_LEARNINGS=1 before running prescribe:

CLAWDOC_LEARNINGS=1 bash {baseDir}/scripts/diagnose.sh <session.jsonl> | bash {baseDir}/scripts/prescribe.sh

Tips

  • Session JSONL files are the ground truth for all diagnostics
  • Use jq -s (slurp) for aggregations across all lines in a session file
  • Filter message.content[] by type=="text" for readable content, type=="toolCall" for tool invocations
  • When prescribing config changes, always show the exact JSON path and value

版本历史

共 1 个版本

  • v0.12.0 当前
    2026-03-30 15:09 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,396 📥 322,578
ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 835 📥 307,169
ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,099 📥 826,312