BC agent-token-usage
Summarize per-agent LLM token consumption for OpenClaw multi-agent setups by parsing `~/.openclaw/agents/*/sessions/<id>.jsonl` session logs (type=message, role=assistant). Ships both a CLI (Python) and an optional 📊 button injected into the Control UI header next to Search. Use when the user asks "今天哪个 agent 用了多少 token / 消耗了多少 token / token 排行 / token 统计 / how much did agent X spend today / which agent burns the most tokens / token usage breakdown / billable token estimate", or asks to install/remove the 📊 token-usage button in Control UI. Returns a ranked table with input / output / cacheRead / cacheWrite / total (and equivalent-billable token estimate). NOT for: dollar cost (use codexbar/model-usage skill), per-message inspection (use sessions_history), or non-OpenClaw runtimes.
As a process C 58/100 · Has gaps — weak spots: result and completion, inputs and preconditions, failures and branches
What is at stake
The skill contains fragments that, in the wrong hands, cost money or data. Below: what the installer risks and what the author should do.
The skill contains commands that delete files, rewrite disks or execute code fetched from the network. The agent may run them without asking if it believes the instructions require it.
Replace destructive commands with safe equivalents that ask for confirmation, scope them to one folder, and stop piping curl into a shell: pin a version and a checksum.
How to improve
- Address the high-severity findings: each costs 18 safety points. If one is a false positive, add the rule id to guard.allow in spec.yaml.
- Your own cases (evals/evals.json, 4–6 real requests with expected answers): the full check would then run those instead of a model-drafted suite.
- A spec.yaml with trigger phrases and assertions — a behaviour contract for CI; `skilltest init` writes a template.
Guard findings · 3
-
high Dangerous commands
cmd-persistenceapply-ui.sh:114Persistence mechanism (cron / launchd / scheduled task / autorun registry)launchctl load "$PLIST" && green "✓ launchd job installed (refreshes every 5min): $LABEL"
Medium and low: 2
-
medium Dangerous commands
cmd-persistenceapply-ui.sh:96Persistence mechanism (cron / launchd / scheduled task / autorun registry) (string literal in code, not executed)PLIST="$HOME/Library/LaunchAgents/$LABEL.plist"
code literal -
medium Dangerous commands
cmd-persistenceremove-ui.sh:5Persistence mechanism (cron / launchd / scheduled task / autorun registry) (string literal in code, not executed)PLIST="$HOME/Library/LaunchAgents/$LABEL.plist"
code literal
Files scanned: 7. Evidence is masked. Grey chips explain why severity was lowered.
Against the Agent Skills spec
- warning
frontmatter-yamlSKILL.md: the frontmatter is not valid YAML (YAML parse error: Nested mappings are not allowed in compact mappings at line 2, column 14: description: Summarize per-agent LLM token consumption for OpenClaw multi-agent… ^ ); fields were read line by line. The usual cause is a colon inside an unquoted value
Process rating: all ten parameters 58/100
- 0Result and completion. Does not say what the result is
- 0Inputs and preconditions. Does not say what the process needs to start
- 0Failures and branches. Linear process with no failure handling
- 60Tools and files. Uses tools (bash, web) that frontmatter does not declare
- 100Steps. 11 steps
- 100When it triggers. States when to use and when not to
- 100Consistency. Name and required fields are in place
- 100Execution cost. Instruction body is 1257 tokens
- 100Running it twice. Mutating operations check current state
- 100Progress reporting. Reports progress
Everything here is measured from the skill text rather than judged by a model, so the numbers are checkable. A parameter weighs more when it is a more common reason for the process to stall.
Quality signals
- +5Description has no quoted example phrases that should trigger the skill
- +3Output format is not stated: the model decides each time
- +1No license
- +2Single-language instructions
- +4Description says when NOT to use the skill
- +3Description length 794: enough signal without eating the budget
- +4Structure: 10 headings
- +3Step-by-step instructions: 11 items
- +4Has examples (5 code blocks)
- +3All 3 scripts are documented
Quality base 70; lint remarks subtract, signals add up to 100. Result: 81.