← 返回 Skills 市场
symbolstar

Agent Token Usage

作者 SymbolStar · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ 安全检测通过
43
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install agent-token-usage
功能描述
Summarize daily LLM token usage per OpenClaw agent from trajectory logs, showing input, output, cache reads/writes, total, and optional billable token estima...
使用说明 (SKILL.md)

agent-token-usage

Accurately attribute LLM token consumption across all OpenClaw agents for a given day.

Why this skill exists

sessions_list returns each session's totalTokens field which is the last context window size, NOT the cumulative consumption across all LLM calls in that session. For long-running sessions with many turns, real consumption can be 100×+ larger than what sessions_list shows. This skill reads the authoritative trajectory.jsonl files where each LLM call writes a usage object, and sums them per agent.

Quick start

# default = today, Asia/Shanghai local date
python ~/.openclaw/workspace/skills/agent-token-usage/scripts/agent_token_usage.py

# specific date
python ~/.openclaw/workspace/skills/agent-token-usage/scripts/agent_token_usage.py --date 2026-05-20

# also show equivalent billable token (cacheRead × 0.1 + cacheWrite × 1.25 + input + output)
python ~/.openclaw/workspace/skills/agent-token-usage/scripts/agent_token_usage.py --date 2026-05-20 --billable

# JSON for downstream tools
python ~/.openclaw/workspace/skills/agent-token-usage/scripts/agent_token_usage.py --date 2026-05-20 --format json

What the columns mean

字段 含义 计费权重
input 新的、未缓存的 prompt token 1.0×
output 模型生成的 token 1.0× (typically 5× input price)
cacheRead 命中 prompt cache 的 token ~0.1×
cacheWrite 写入 prompt cache 的 token ~1.25×
total 四者之和(真实通过 LLM 的 token 量
~bill 等效计费 token(按权重折算)

total 看「谁在烧 LLM 算力」,用 ~bill 看「谁更费钱」。 两者结论可能完全不同 —— 高 cacheRead 的 agent 看似巨大其实便宜,低 cacheWrite 但全 input 的 agent 看似小其实贵。

How it works

  1. Walk ~/.openclaw/agents/\x3Cagent>/sessions/*.trajectory.jsonl
  2. For each line, check ts startswith target date (ISO YYYY-MM-DD)
  3. DFS-search the data field for a usage dict with token counters
  4. Sum per agent; also track session count and models used

Trajectory files use schema openclaw-trajectory v1. The usage object lives inside model-response events emitted by the runtime.

Common follow-ups

  • "按等效成本排名"--billable
  • "昨天的"--date YYYY-MM-DD
  • "导出给我"--format json > /tmp/usage.json
  • "为什么 sessions_list 的数字差这么多" → 解释:sessions_list.totalTokenscontext size,不是 cumulative spend。本 skill 直接累加每次 LLM 调用的 usage。

Caveats

  • Only counts events that have a usage object — non-LLM tool calls (exec, read, write) are excluded by design
  • The 0.1× / 1.25× cache multipliers are Anthropic ballpark numbers; for OpenAI / other providers adjust mentally
  • Does NOT compute USD cost — use the model-usage skill (CodexBar cost log) when the user asks for $ amounts
  • --date is matched against ISO timestamps in trajectory (which are UTC); for very late-night events this can shift by a day relative to local time. For Asia/Shanghai users this matters between 00:00-08:00 local
安全使用建议
Do not treat this as a complete security review. Install only after metadata.json and the artifact directory are successfully inspected by a reviewer or scanner.
能力评估
Purpose & Capability
Review is incomplete because workspace file access failed before metadata.json or artifact contents could be read.
Instruction Scope
No artifact instructions were available to assess for scope, overrides, or unsafe agent behavior.
Install Mechanism
No install specification or manifest content was available to evaluate.
Credentials
No artifact evidence was available to judge whether requested environment access is proportionate.
Persistence & Privilege
No artifact evidence was available showing persistence, privilege use, or credential handling.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install agent-token-usage
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /agent-token-usage 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Initial release: per-agent daily LLM token consumption from OpenClaw trajectory files, with billable-equivalent estimate
元数据
Slug agent-token-usage
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Agent Token Usage 是什么?

Summarize daily LLM token usage per OpenClaw agent from trajectory logs, showing input, output, cache reads/writes, total, and optional billable token estima... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 43 次。

如何安装 Agent Token Usage?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install agent-token-usage」即可一键安装,无需额外配置。

Agent Token Usage 是免费的吗?

是的,Agent Token Usage 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Agent Token Usage 支持哪些平台?

Agent Token Usage 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Agent Token Usage?

由 SymbolStar(@symbolstar)开发并维护,当前版本 v0.1.0。

💬 留言讨论