Summary
I've observed an intermittent issue where the openclaw status --json command (and consequently the session_status tool) reports a negative value for inputTokens for the main agent's current session.
Steps to reproduce
- Initiate a long-running OpenClaw session with continuous interaction.
- Periodically run
openclaw status --json from a separate process (e.g., via a Python script calling subprocess.run(["openclaw", "status", "--json"], ...) or directly via exec tool).
- Note: The
stdout of openclaw status --json often includes non-JSON lines (e.g., [plugins] ... registration messages, gateway connect failed) before the actual JSON object. This non-JSON prefix needs to be handled if parsing the output programmatically.
- Observe the
inputTokens value in the sessions.recent[0].inputTokens field within the parsed JSON output.
Expected behavior
inputTokens should always be a non-negative (zero or positive) integer, representing the cumulative tokens consumed by the session.
Actual behavior
When running openclaw status --json (or session_status within an agent's context), the inputTokens field in the JSON output occasionally shows a negative number (e.g., -284957, -296318). outputTokens appears to remain positive.
This occurs seemingly randomly and affects the accuracy of token usage tracking.
OpenClaw version
2026.2.19-2 (45d9b20) (as per openclaw status output)
Operating system
Linux 6.17.0-1008-gcp (x64)
Install method
package (pnpm)
Logs, screenshots, and evidence
Please attach the complete log output from running `openclaw status --json` when a negative `inputTokens` value is observed. (e.g., copy-paste terminal output or take a screenshot).
Impact and severity
Impact:
- Leads to inaccurate reporting of token usage.
- Breaks downstream scripts designed to track and summarize token consumption, as negative values are unexpected and logically incorrect for cumulative usage.
Severity: High (as it affects the accuracy of a core metric)
Additional information
Temporary Mitigation (Agent-side):
As a workaround, my agent-side script (record_tokens.py) that logs token usage now clamps any negative inputTokens values to 0 before recording, but this does not fix the root cause in the OpenClaw core.
Summary
I've observed an intermittent issue where the
openclaw status --jsoncommand (and consequently thesession_statustool) reports a negative value forinputTokensfor the main agent's current session.Steps to reproduce
openclaw status --jsonfrom a separate process (e.g., via a Python script callingsubprocess.run(["openclaw", "status", "--json"], ...)or directly viaexectool).stdoutofopenclaw status --jsonoften includes non-JSON lines (e.g.,[plugins] ...registration messages,gateway connect failed) before the actual JSON object. This non-JSON prefix needs to be handled if parsing the output programmatically.inputTokensvalue in thesessions.recent[0].inputTokensfield within the parsed JSON output.Expected behavior
inputTokensshould always be a non-negative (zero or positive) integer, representing the cumulative tokens consumed by the session.Actual behavior
When running
openclaw status --json(orsession_statuswithin an agent's context), theinputTokensfield in the JSON output occasionally shows a negative number (e.g.,-284957,-296318).outputTokensappears to remain positive.This occurs seemingly randomly and affects the accuracy of token usage tracking.
OpenClaw version
2026.2.19-2 (45d9b20)(as peropenclaw statusoutput)Operating system
Linux 6.17.0-1008-gcp (x64)Install method
package(pnpm)Logs, screenshots, and evidence
Impact and severity
Impact:
Severity: High (as it affects the accuracy of a core metric)
Additional information
Temporary Mitigation (Agent-side):
As a workaround, my agent-side script (
record_tokens.py) that logs token usage now clamps any negativeinputTokensvalues to 0 before recording, but this does not fix the root cause in the OpenClaw core.