Session Cost for Openclaw

A financial monitoring tool for Openclaw Skills that parses session transcripts to calculate per-model spend and enforce strict budget limits.

imaflytok
v1.0.0
Mar 2, 2026
0
543
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install agent-session-cost

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install agent-session-cost using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Session Cost?

The Session Cost skill provides developers with essential visibility into the financial overhead of running autonomous agents. By programmatically parsing local session logs, it enables users to identify expensive workflows and maintain strict control over their AI consumption. This utility is a critical component for anyone scaling agentic operations within the Openclaw Skills ecosystem.

It functions by scanning the standardized directory structure of your agents, extracting usage metadata, and aggregating it into actionable reports. Whether you are running a single agent or a complex swarm, this skill ensures that API costs remain transparent, predictable, and fully audited.

Session Cost Use Cases

  • Monitoring daily API expenditure to prevent unexpected billing spikes in your Openclaw Skills projects.
  • Identifying the most expensive models in your stack to optimize performance versus cost efficiency.
  • Setting up automated budget alerts that notify a human operator when spending thresholds are crossed.
  • Auditing historical session data to calculate the average cost-per-task for different agent configurations.

How Session Cost Works

  1. The skill accesses the local file system to locate JSONL session logs stored within the Openclaw Skills directory structure.
  2. It filters session files based on creation timestamps or directory paths to target specific timeframes, such as the last 24 hours.
  3. The script iterates through each log entry, specifically targeting the usage and cost metadata nested within the message objects.
  4. It aggregates these values to calculate total spend, average session cost, and per-model financial impact.
  5. The resulting data is formatted into a clean CLI report or used to trigger budget alerts if thresholds are exceeded.

Session Cost Setup

To utilize this skill, ensure your environment is configured for Openclaw Skills and that you have Python 3 installed. You can check the cost of your most recent session immediately by running the following command in your terminal:

LATEST=$(ls -t ~/.openclaw/agents/main/sessions/*.jsonl 2>/dev/null | head -1)
[ -n "$LATEST" ] && python3 -c "
import json
total = 0
with open('$LATEST') as f:
    for line in f:
        entry = json.loads(line)
        cost = entry.get('message',{}).get('usage',{}).get('cost',{}).get('total',0)
        if cost: total += cost
print(f'Session cost: ${total:.4f}')
" || echo "No sessions found"

Session Cost Data Schema & Taxonomy

The Session Cost skill interacts with the standard JSONL format used across Openclaw Skills. It maps the following data points:

Property Description
message.model The specific LLM model used for a turn, used for per-model breakdowns.
message.usage.cost.total The precise financial cost of an individual turn in the session.
~/.openclaw/agents/*/sessions/ The standard directory path where session data is retrieved.
mtime File modification time used to calculate daily or hourly spend summaries.

Session Cost Advanced Features

  • Multi-agent aggregation to track total spend across an entire swarm of Openclaw Skills.
  • Automated heartbeat integration that triggers a system alert if the daily budget exceeds a user-defined limit (e.g., $15).
  • Per-model financial breakdown to compare the cost-effectiveness of different providers like Anthropic or OpenAI.
  • Time-window filtering for granular reporting on specific development sprints or testing sessions.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*