Skip to content

Bug: Usage page doesn't count tokens from reset and delete sessions #42032

@liyd

Description

@liyd

Bug Report

Summary

The Usage page in Control UI shows significantly lower token/cost usage than actual. After investigating locally, I found that the Gateway only counts tokens from active .jsonl session files, but ignores .jsonl.reset.* archived files generated by /new or session resets.

Steps to Reproduce

  1. Use OpenClaw normally across multiple sessions, using /new to reset between topics
  2. Open Control UI → Usage page → select last 7 days
  3. Observe that token counts are far lower than actual usage

Root Cause

Each /new or session reset renames the active session file from:

<uuid>.jsonl  →  <uuid>.jsonl.reset.<timestamp>

The .jsonl.reset.* files contain full token usage data (input, output, cacheRead, cacheWrite, cost), but the sessions.usage / sessions.usage.timeseries WebSocket handlers appear to only scan active .jsonl files, skipping the reset archives.

Evidence

Inspecting a reset session file shows valid usage data:

{
  "input": 18443,
  "output": 129,
  "cacheRead": 2560,
  "cacheWrite": 0,
  "totalTokens": 21132,
  "cost": { "total": 0.0117 }
}

In my local setup, there are 31 reset files and 12 deleted files for the main agent — none of these appear in the Usage dashboard.

Expected Behavior

.jsonl.reset.* files should be included in Usage statistics. These represent real usage from the same user/agent — the session was just reset, not deleted.

Notes

  • .jsonl.deleted.* files (manually deleted sessions) — reasonable to exclude
  • .jsonl.reset.* files (reset via /new) — should be counted

Environment

  • OpenClaw version: 2026.3.8
  • OS: macOS (Darwin 23.6.0, arm64)
  • Node: v22.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions