openclaw - 💡(How to fix) Fix Usage dashboard loses historical data on session reset (/new) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#50067Fetched 2026-04-08 00:59:33
View on GitHub
Comments
2
Participants
2
Timeline
2
Reactions
0
Author
Timeline (top)
commented ×2

The /usage dashboard at http://127.0.0.1:18789/usage only reads active session .jsonl files. When a session is reset via /new, the transcript file is renamed to .jsonl.reset.<timestamp> and the dashboard stops counting its usage data.

This means:

  • Date-range filters (7d, 30d, custom) show incomplete data
  • Total costs are understated after any /new or /reset
  • The dashboard suggests it tracks historical usage, but it effectively resets on every session change

Root Cause

The /usage dashboard at http://127.0.0.1:18789/usage only reads active session .jsonl files. When a session is reset via /new, the transcript file is renamed to .jsonl.reset.<timestamp> and the dashboard stops counting its usage data.

This means:

  • Date-range filters (7d, 30d, custom) show incomplete data
  • Total costs are understated after any /new or /reset
  • The dashboard suggests it tracks historical usage, but it effectively resets on every session change

Fix Action

Workaround

Parse all .jsonl* files directly with a script to get accurate totals.

RAW_BUFFERClick to expand / collapse

Summary

The /usage dashboard at http://127.0.0.1:18789/usage only reads active session .jsonl files. When a session is reset via /new, the transcript file is renamed to .jsonl.reset.<timestamp> and the dashboard stops counting its usage data.

This means:

  • Date-range filters (7d, 30d, custom) show incomplete data
  • Total costs are understated after any /new or /reset
  • The dashboard suggests it tracks historical usage, but it effectively resets on every session change

Steps to Reproduce

  1. Start a session, use it for a while (accumulate some cost)
  2. Note the usage shown in the /usage dashboard
  3. Run /new to start a fresh session
  4. Check the /usage dashboard again — the previous session's cost is gone
  5. Switch to 7-day or 30-day filter — still missing

Evidence

Session log files in ~/.openclaw/agents/main/sessions/:

  • Active sessions (.jsonl): 4 files, $4.15 total
  • Archived sessions (.jsonl.reset.* + .jsonl.deleted.*): 22 files, $125.71 total
  • Real total: $129.86 across 26 files

The archived files contain full message.usage.cost data with timestamps — all the information needed for accurate historical reporting.

Expected Behavior

The /usage dashboard should aggregate cost data from all session log files (.jsonl, .jsonl.reset.*, .jsonl.deleted.*) when applying date-range filters, not just active sessions.

Environment

  • OpenClaw v2026.3.13
  • macOS (Apple Silicon)
  • Gateway running as daemon

Workaround

Parse all .jsonl* files directly with a script to get accurate totals.

extent analysis

Fix Plan

To fix the issue, we need to modify the /usage dashboard to read and aggregate data from all session log files, including .jsonl.reset.* and .jsonl.deleted.* files.

Steps:

  • Update the file reading logic to include all relevant file types
  • Modify the data aggregation function to handle the new file types

Example Code:

import glob
import json

def read_session_files(directory):
    # Read all relevant session log files
    files = glob.glob(f"{directory}/*.jsonl*")
    data = []
    for file in files:
        with open(file, 'r') as f:
            for line in f:
                data.append(json.loads(line))
    return data

def aggregate_usage_data(data):
    # Aggregate cost data from all session log files
    usage_data = {}
    for entry in data:
        timestamp = entry['timestamp']
        cost = entry['message']['usage']['cost']
        date = timestamp.split('T')[0]
        if date not in usage_data:
            usage_data[date] =  usage_data[date] += cost
    return usage_data

# Example usage:
directory = "~/.openclaw/agents/main/sessions/"
data = read_session_files(directory)
usage_data = aggregate_usage_data(data)
print(usage_data)

Verification

To verify that the fix worked, check the /usage dashboard after applying the changes and ensure that it displays accurate historical usage data, including data from archived sessions.

Extra Tips

  • Make sure to update the file reading logic to handle any potential errors or edge cases.
  • Consider adding additional logging or monitoring to ensure that the fix is working as expected.
  • Review the code changes to ensure they are compatible with future updates to OpenClaw.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Usage dashboard loses historical data on session reset (/new) [2 comments, 2 participants]