Token导航 LogoToken导航TokenDH.com
研究检索需要联网clawhub未标认证来源可访问clear审计通过

session-cost会话成本

Agent Skill

session-cost 用于查找、检索和筛选相关信息,适合在 OpenClaw 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

70,625

周安装

2,885

GitHub Stars

1

下载量

22,618
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:session-cost(会话成本)
来源仓库:https://github.com/khaney64/session-cost
安装命令:
openclaw skills install session-cost
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install session-cost

简介

会话成本分析工具用于统计 OpenClaw 会话的令牌使用与支出。

  • 适合按代理和模型分组查看性能指标,辅助预算管理。
  • 可生成详细报告,帮助用户优化 API 调用策略。
  • 依赖日志文件完整性,请确保 session logs 已正确启用。
  • session-cost 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

name
session-cost
description
Analyze OpenClaw session logs to report token usage, costs, and performance metrics grouped by agent and model. Use when the user asks about API spending, token usage, session costs, or wants a usage summary.
metadata
{"openclaw":{"emoji":"📊","requires":{"bins":["node"]}}}

Session Cost

Analyze OpenClaw session logs for token usage, costs, and performance metrics grouped by agent and model.

By default, scans all agents in ~/.openclaw/agents/. Each agent's sessions are read from ~/.openclaw/agents/<name>/sessions/.

Quick Start

# Summary across all agents
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js

# Show all session details
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --details

# Show details for a specific session (searches across all agents)
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --details abc123

Options

  • --path <dir> — Directory to scan for .jsonl files (overrides agent auto-discovery)
  • --agent <name> — Filter by agent name (e.g., main, codegen)
  • --offset <time> — Only include sessions from the last N units (30m, 2h, 7d)
  • --provider <name> — Filter by model provider (anthropic, openai, ollama, etc.)
  • --details [session-id] — Show per-session details. Optionally pass a session ID to show just that session (searches across all agents for <id>.jsonl)
  • --table — Show details in compact table format (use with --details)
  • --format <type> — Output format: text (default), json, or discord
  • --json — Shorthand for --format json (backwards compat)
  • --help, -h — Show help message

Examples

# Last 24 hours summary
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --offset 24h

# Only the main agent
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --agent main

# Last 7 days, JSON output
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --offset 7d --json

# Discord-friendly format (for bots/chat)
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --format discord

# Discord format with filters
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --format discord --offset 24h --provider anthropic

# Filter by provider
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --provider anthropic

# All sessions in compact table format
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --details --table

# Custom path with details (overrides agent discovery, scans exact directory)
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --path /other/dir --details

# Single session detail (found automatically across agents)
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --details 9df7a399-8254-411b-a875-e7337df73d29

# Anthropic sessions from last 24h in table format
node /home/claw/.openclaw/workspace/skills/session-cost/scripts/session-cost.js --provider anthropic --offset 24h --details --table

Output Format

Text Summary (Default)

Results are grouped by agent, then by model within each agent. A grand total section shows per-agent subtotals and a combined total.

Found 52 .jsonl files across 2 agents, 52 matched

====================================================================================================
SUMMARY BY AGENT
====================================================================================================

Agent: main

  anthropic/claude-sonnet-4-5-20250929
  --------------------------------------------------------------------------------
    Sessions: 30
    Tokens:   1,234,567 (input: 900,000, output: 334,567)
    Cache:    read: 500,000 tokens, write: 200,000 tokens
    Cost:     $12.3456
      Input:       $5.4000
      Output:      $5.0185
      Cache read:  $1.5000  (included in total, discounted rate)
      Cache write: $0.4271  (included in total)

  anthropic/claude-opus-4-6
  --------------------------------------------------------------------------------
    Sessions: 5
    Tokens:   250,000 (input: 180,000, output: 70,000)
    ...

Agent: codegen

  anthropic/claude-sonnet-4-5-20250929
  --------------------------------------------------------------------------------
    Sessions: 17
    ...

====================================================================================================
GRAND TOTAL
====================================================================================================
  main                 — 35 sessions, $15.8200
  codegen              — 17 sessions, $8.5600

All agents (2)
--------------------------------------------------------------------------------
  Sessions: 52
  Tokens:   ...
  Cost:     $24.3800
  ...

When only a single agent is present, the grand total shows "All models (N)" instead.

Text Details (--details)

Shows per-session breakdown (session ID, agent, model, duration, timestamps, tokens, cache, cost) followed by the agent/model summary.

Table Format (--details --table)

Compact table view. When multiple agents are present, an Agent column is included.

SESSION DETAILS
============================================================================================================================================
Agent          Model                              Duration    Tokens        Cache               Cost        Session
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
main           anthropic/claude-sonnet-4.5        45 min      128.5K        15.2K / 8.1K        $0.3245     abc123def456
codegen        anthropic/claude-sonnet-4.5        12 min      45.3K         2.1K / 1.5K         $0.8921     xyz789abc012

With a single agent, the Agent column is omitted and the table matches the previous format.

JSON (--format json)

Results are nested by agent. Each agent contains its model summaries and an agent-level totals object. A top-level grandTotal aggregates across all agents.

{
  "agents": {
    "main": {
      "models": {
        "anthropic/claude-sonnet-4-5-20250929": {
          "sessions": 30,
          "tokens": { "input": 900000, "output": 334567, "total": 1234567 },
          "cache": { "read": 500000, "write": 200000 },
          "cost": { "total": 12.3456, "input": 5.4, "output": 5.0185, "cacheRead": 1.5, "cacheWrite": 0.4271 }
        }
      },
      "totals": {
        "sessions": 35,
        "tokens": { "input": 1080000, "output": 404567, "total": 1484567 },
        "cache": { "read": 600000, "write": 250000 },
        "cost": { "total": 15.82, ... }
      }
    },
    "codegen": {
      "models": { ... },
      "totals": { ... }
    }
  },
  "grandTotal": {
    "sessions": 52,
    "tokens": { "input": 1500000, "output": 600000, "total": 2100000 },
    "cache": { "read": 800000, "write": 350000 },
    "cost": { "total": 24.38, ... }
  }
}

Discord (--format discord)

Optimized for chat platforms (Discord, Slack, etc.) - concise, markdown-friendly, no tables:

💰 **Usage Summary**
(last 24h)

**Total Cost:** $24.38
**Total Tokens:** 2.1M
**Sessions:** 52

**By Agent:**
• main: $15.82 (35 sessions)
• codegen: $8.56 (17 sessions)

**By Provider:**
• anthropic: $22.50 (1.9M tokens)
• openai: $1.88 (200K tokens)

**Top Models:**
• anthropic/claude-sonnet-4.5: $18.20 (1.5M tokens)
• anthropic/claude-opus-4: $4.30 (400K tokens)
• openai/gpt-4o: $1.88 (200K tokens)

The "By Agent" section is shown only when multiple agents are present.

Output Fields

  • Agent — Agent name (derived from directory under ~/.openclaw/agents/)
  • Sessions — Number of session files analyzed
  • Tokens — Total, input, and output token counts
  • Cache — Cache read and write token counts
  • Cost — Total cost broken down by input, output, cache read, and cache write
  • Duration — Session duration in minutes (details mode)
  • Timestamps — First and last activity timestamps (details mode)

Notes

  • When --path is provided, it overrides agent auto-discovery and scans exactly that directory. The agent name is inferred from the path (e.g., .../agents/main/sessions → "main").
  • --agent and --provider filters can be combined (e.g., --agent main --provider anthropic).
  • Single session lookup (--details <id>) searches across all discovered agents to find the session file.
  • *.trajectory.jsonl files are skipped — they use a different schema and would otherwise show up as unknown/unknown rows with zero tokens.
  • Local models (Ollama, etc.) that genuinely report zero token usage display (not reported by model) next to the token counts so they can be distinguished from sessions with no assistant activity.

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

79.45%
按下载量换算17,970

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills