Skip to content

Control UI shows incorrect context percentage (always 100% after compaction) #51060

@itsBrolie

Description

@itsBrolie

Bug Description

The Control UI message metadata shows incorrect context percentage after LCM compaction.

Current Behavior

Control UI displays: ↑293.3k ↓1.7k 100% ctx glm-5:cloud
/status command shows: Context 53k/200k (27%)

Expected Behavior

Both should show the current context usage, not cumulative tokens.

Root Cause

In control-ui/assets/index-UvgeZ3yV.js:

// Line ~645
let l = t && n > 0 ? Math.min(Math.round(n / t * 100), 100) : null;

// n = Sum of ALL input tokens across session (cumulative)
// t = Context window limit (200k)

The calculation uses cumulative input tokens instead of current context tokens after compaction.

When cumulative tokens exceed the context limit, it caps at 100%, making the metric meaningless.

Correct Calculation

Should use session.totalTokens (post-compaction) instead of cumulative input, similar to how /status calculates it:

// From auth-profiles-DDVivXkv.js line 117996
const totalsLine = session.totalTokens != null 
  ? `Session tokens (cached): ${formatInt(session.totalTokens)} total / ctx=${session.contextTokens ?? "?"}` 
  : `Session tokens (cached): unknown / ctx=${session.contextTokens ?? "?"}`;

Impact

  • Users see misleading "100% ctx" when context is actually healthy post-compaction
  • Defeats the purpose of LCM (Lossless Context Management) transparency

Environment

  • OpenClaw version: 2026.3.13
  • Model: ollama/glm-5:cloud (200k context window)
  • LCM compaction: active

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