Agents/status: preserve carried-forward session token totals for providers that omit usage metadata, so `/status` and `openclaw sessions` keep showing the last known context usage instead of dropping back to unknown/0%.
Troubleshooting guide for fixes introduced in OpenClaw v2026.4.19-beta.2.
Symptoms
If you are using a provider that does not include usage metadata in its API responses (such as MiniMax via its Anthropic-compatible endpoint), you may notice the following symptoms:
- Running
/statusshowsContext: 0/264k (0%)even after extensive conversations with thousands of messages. - The
openclaw sessionscommand displaysunknownor0%for context usage despite recent activity. - After session compaction, the context usage counter resets to zero instead of reflecting the compacted value.
These symptoms occur without any explicit error messages, making the issue easy to overlook until you notice the incorrect usage display.
Root Cause
The root cause lies in how the session store handles token usage data from API responses. When a provider does not include usage metadata (input_tokens, output_tokens) in its response, the hasNonzeroUsage() check in persistSessionAfterRun (src/agents/command/session-store.ts) returns false. This causes the entire totalTokens update block to be skipped.
As a result, the session entry retains totalTokens: undefined, and the /status command interprets this undefined value as 0% context usage. The session never accumulates token totals across multiple runs, even though prior runs or compaction operations may have already calculated this information.
Step-by-Step Fix
To resolve this issue, upgrade to version v2026.4.19-beta.2 or later. The fix preserves existing totalTokens values when the current run lacks usage data, preventing the counter from resetting to zero.
If you cannot upgrade immediately, you can manually verify your session state by checking the session file directly:
cat ~/.openclaw/sessions/<session-id>.json | grep totalTokens
If the value is null or missing, the context usage display will show 0% until you upgrade or the provider begins sending usage metadata.
Verification
After upgrading to v2026.4.19-beta.2, verify the fix is working by:
- Starting a new session or continuing an existing one.
- Running
/statusto confirm the context usage displays your last known value instead of0%. - Running
openclaw sessions listand checking that the context usage column shows a meaningful percentage rather thanunknownor0%.
If the value is preserved but not actively updated, you may see a stale indicator (such as totalTokensFresh: false in debug output). This is expected behavior—the system now shows the last known usage rather than masking it with zeros.
Common Pitfalls
- Provider compatibility: This fix applies specifically to providers that omit usage metadata. If your provider includes usage data in every response, this issue would not occur, and the fix has no impact on your workflow.
- Session compaction: The preserved value reflects the state before the last compaction. After compaction, the session may restart with a new
totalTokensbaseline, which is normal behavior. - Debugging: If you need to inspect the raw session data, use
openclaw sessions debug <session-id>to view the internal session object, including thetotalTokensFreshflag.
Related Errors
This fix addresses the following:
- Affected versions: Prior to v2026.4.19-beta.2
- Fixed versions: v2026.4.19-beta.2 and later
- Related command:
/status - Related command:
openclaw sessions - Linked issue: Fixes #67667
If you encounter persistent issues after upgrading, ensure your provider is correctly configured and that API responses include the required metadata fields. Contact support if the problem persists.