Summary
/status can show misleading context usage when session token totals are stale.
When totalTokens is missing and totalTokensFresh=false, the status output currently falls back to inputTokens + outputTokens, which can display values like 299k/200k (149%) even though true context occupancy is unknown.
Why this is a problem
- It looks like auto-compaction failed, while
Compactions may still be 0.
- It conflates cumulative accounting usage with current in-window context usage.
- Operators cannot distinguish "unknown" from "actually overflowing".
Repro
- Use a session entry where:
totalTokens: null
totalTokensFresh: false
inputTokens: 298437
outputTokens: 147
contextTokens: 200000
- Run
/status.
Observed:
Context: 299k/200k (149%)
Compactions: 0
Expected:
- Context should be shown as unknown (for example
?/200k or unknown/200k), not inferred from input+output when freshness is false.
Root cause (code)
In status rendering path, total tokens are computed as:
totalTokens = entry.totalTokens ?? (entry.inputTokens + entry.outputTokens)
without checking totalTokensFresh.
Proposed fix
- Only trust
entry.totalTokens when fresh (totalTokensFresh !== false).
- Do not synthesize context occupancy from
input+output when totals are stale.
- Keep transcript-usage override path (if available) to recover an actually useful total.
- Add regression test for
totalTokensFresh=false.
Version
Observed in OpenClaw 2026.3.11 (commit shown by openclaw --version).
Summary
/statuscan show misleading context usage when session token totals are stale.When
totalTokensis missing andtotalTokensFresh=false, the status output currently falls back toinputTokens + outputTokens, which can display values like299k/200k (149%)even though true context occupancy is unknown.Why this is a problem
Compactionsmay still be0.Repro
totalTokens: nulltotalTokensFresh: falseinputTokens: 298437outputTokens: 147contextTokens: 200000/status.Observed:
Context: 299k/200k (149%)Compactions: 0Expected:
?/200korunknown/200k), not inferred frominput+outputwhen freshness is false.Root cause (code)
In status rendering path, total tokens are computed as:
totalTokens = entry.totalTokens ?? (entry.inputTokens + entry.outputTokens)without checking
totalTokensFresh.Proposed fix
entry.totalTokenswhen fresh (totalTokensFresh !== false).input+outputwhen totals are stale.totalTokensFresh=false.Version
Observed in OpenClaw
2026.3.11(commit shown byopenclaw --version).