openclaw - 💡(How to fix) Fix Dashboard /compact silently wipes context once Claude CLI session is over the 1M cap

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Three related bugs make the Dashboard's context-usage display misleading and turn /compact into a silent context wipe once the underlying Claude CLI session crosses Anthropic's 1M-token limit:

  1. Meter math is wrongtotalTokens (cumulative lifetime tokens billed) is displayed as if it were current window fill. The bar only climbs and reaches 100% long before the live context is full.
  2. Dashboard "Compact" button is inert — clicking it produces no visible state change. Users fall back to typing /compact.
  3. /compact past the cap silently rotates to a fresh session, losing all context. The summarizer is called with an empty <conversation> payload and dutifully writes a (none) placeholder summary; no carry-over occurs.

The combination means: by the time a user realises they should compact, both the button and the slash command fail to do anything useful, and the slash command quietly destroys the conversation.

Error Message

  • Compact button: wired to the same code path as /compact, with visible state and error reporting.

Root Cause

Three related bugs make the Dashboard's context-usage display misleading and turn /compact into a silent context wipe once the underlying Claude CLI session crosses Anthropic's 1M-token limit:

  1. Meter math is wrongtotalTokens (cumulative lifetime tokens billed) is displayed as if it were current window fill. The bar only climbs and reaches 100% long before the live context is full.
  2. Dashboard "Compact" button is inert — clicking it produces no visible state change. Users fall back to typing /compact.
  3. /compact past the cap silently rotates to a fresh session, losing all context. The summarizer is called with an empty <conversation> payload and dutifully writes a (none) placeholder summary; no carry-over occurs.

The combination means: by the time a user realises they should compact, both the button and the slash command fail to do anything useful, and the slash command quietly destroys the conversation.

Fix Action

Fix / Workaround

Workaround for affected users

Code Example

~/.claude/projects/-home-magnus--openclaw-workspace/
  30c88639-...jsonl   1,479,657 bytes   2026-05-26T11:172026-05-27T12:00 UTC   ← over-cap session
  63b2fc26-...jsonl     260,503 bytes   2026-05-27T12:0312:08                  ← rotation 1
  f0fb40ea-...jsonl     482,442 bytes   2026-05-27T12:1612:21                  ← rotation 2 (terminated mid-reply)
  2985275a-...jsonl     253,358 bytes   2026-05-27T12:2312:32                  ← rotation 3 (current)

---

12:21:17.598Z  assistant: "I now have enough to explain both issues. But before I make the call on (2), let me confirm WHY the compaction summariser saw 'empty' — I want to see the prompt builder."
12:21:19.226Z  assistant: ""
12:21:19.455Z  user:      ""
12:21:22.973Z  assistant: ""
12:21:23.211Z  user:      ""
12:21:25.722Z  assistant: ""
12:21:25.724Z  user:      ""
                          [session ends]

---

"compactionCount": 1,
"compactionCheckpoints": [{
  "checkpointId": "79b941ed-…",
  "reason": "manual",
  "tokensBefore": 1567,
  "summary": "## Goal\n(No conversation content provided to summarize)\n\n## Constraints & Preferences\n- (none)\n\n## Progress\n### Done\n- (none)\n…\n## Critical Context\n- The conversation block in the prompt was empty; no user/assistant exchanges were available to analyze\n- A valid summary cannot be produced without source conversation content"
}]

---

"totalTokens": 41672,        // post-compact, cumulative since last reset
"totalTokensFresh": true,
"contextTokens": 1048576     // window capacity
RAW_BUFFERClick to expand / collapse

Dashboard /compact silently wipes context when session is over Claude's 1M cap

AI-assisted bug report — written by Mimir (Claude Opus 4.7 via OpenClaw), reviewed and submitted by @magnuspihl.

OpenClaw: 2026.5.22 (a374c3a) Platform: Linux 6.17.0-29-generic x86_64, Node v22.22.2 Model: Anthropic Claude Opus 4.7 via Claude CLI harness Surface: Dashboard (webchat)

Summary

Three related bugs make the Dashboard's context-usage display misleading and turn /compact into a silent context wipe once the underlying Claude CLI session crosses Anthropic's 1M-token limit:

  1. Meter math is wrongtotalTokens (cumulative lifetime tokens billed) is displayed as if it were current window fill. The bar only climbs and reaches 100% long before the live context is full.
  2. Dashboard "Compact" button is inert — clicking it produces no visible state change. Users fall back to typing /compact.
  3. /compact past the cap silently rotates to a fresh session, losing all context. The summarizer is called with an empty <conversation> payload and dutifully writes a (none) placeholder summary; no carry-over occurs.

The combination means: by the time a user realises they should compact, both the button and the slash command fail to do anything useful, and the slash command quietly destroys the conversation.

Repro

  1. Hold a long Dashboard conversation until the live Claude CLI transcript crosses ~1M tokens. (For me this was ~24 hours of work, accumulated 1.5 MB in ~/.claude/projects/<workspace>/<session-id>.jsonl.)
  2. Anthropic's API begins rejecting calls — assistant stops replying.
  3. Click the Dashboard's "Compact" button. Nothing happens.
  4. Type /compact. The reply is NO_REPLY; a fresh Claude CLI session ID is allocated and prior context is gone.

Evidence from my install

Live transcripts (the real conversation lives here, not in OpenClaw's session JSONL)

~/.claude/projects/-home-magnus--openclaw-workspace/
  30c88639-...jsonl   1,479,657 bytes   2026-05-26T11:17 → 2026-05-27T12:00 UTC   ← over-cap session
  63b2fc26-...jsonl     260,503 bytes   2026-05-27T12:03 → 12:08                  ← rotation 1
  f0fb40ea-...jsonl     482,442 bytes   2026-05-27T12:16 → 12:21                  ← rotation 2 (terminated mid-reply)
  2985275a-...jsonl     253,358 bytes   2026-05-27T12:23 → 12:32                  ← rotation 3 (current)

Four distinct Claude CLI session IDs in 30 minutes. None carries memory of any other.

The mid-reply termination at the end of f0fb40ea-…jsonl:

12:21:17.598Z  assistant: "I now have enough to explain both issues. But before I make the call on (2), let me confirm WHY the compaction summariser saw 'empty' — I want to see the prompt builder."
12:21:19.226Z  assistant: ""
12:21:19.455Z  user:      ""
12:21:22.973Z  assistant: ""
12:21:23.211Z  user:      ""
12:21:25.722Z  assistant: ""
12:21:25.724Z  user:      ""
                          [session ends]

OpenClaw's record of the failed compaction (~/.openclaw/agents/main/sessions/sessions.json)

"compactionCount": 1,
"compactionCheckpoints": [{
  "checkpointId": "79b941ed-…",
  "reason": "manual",
  "tokensBefore": 1567,
  "summary": "## Goal\n(No conversation content provided to summarize)\n\n## Constraints & Preferences\n- (none)\n\n## Progress\n### Done\n- (none)\n…\n## Critical Context\n- The conversation block in the prompt was empty; no user/assistant exchanges were available to analyze\n- A valid summary cannot be produced without source conversation content"
}]

Two things are wrong here:

  • tokensBefore: 1567 — should be ~1M+. OpenClaw is reading from the wrong source (looks like the sparse OpenClaw session JSONL, not the live Claude CLI transcript).
  • Summary is the model's polite "I have nothing to summarize" response. The compactor handed it an empty <conversation> payload and wrote the result to disk as a real checkpoint.

Dashboard meter math

sessions.json shows the main session as:

"totalTokens": 41672,        // post-compact, cumulative since last reset
"totalTokensFresh": true,
"contextTokens": 1048576     // window capacity

Before /compact this morning it was totalTokens: 1297578 — i.e. 124% of capacity. The Dashboard was computing totalTokens / contextTokens and reporting "100%". But totalTokens is cumulative tokens billed (counts each turn's full re-sent context anew), not the size of the next request. The number is monotonic and unbounded; using it as a fill ratio means the bar will always reach 100% on a long-lived session regardless of actual context state.

Expected behaviour

  • Meter: show the actual size of the next outgoing request (≈ size of the live Claude CLI transcript file relative to model window). Should rise and fall with compaction.
  • Compact button: wired to the same code path as /compact, with visible state and error reporting.
  • /compact near or past the cap: must succeed or fail loudly, never silently rotate. Possible strategies:
    • Run the summarizer on a smaller-context fallback model that still has headroom.
    • Drop oldest N turns to make room, then retry the summarize call on the primary model.
    • Refuse and tell the user the transcript is over-cap, with a clear "export" or "manual prune" option.
    • At minimum: detect that the summarize call returned (none)/empty and abort the rotation, surfacing the failure instead of writing the placeholder as a real checkpoint.

Suggested investigation entry points

  • Compactor prompt builder: confirm it reads from the Claude CLI transcript (~/.claude/projects/<workspace>/<session-id>.jsonl), not OpenClaw's session JSONL.
  • The path that writes compactionCheckpoints[].summary — should validate the summary is non-trivial before accepting.
  • Dashboard meter computation: locate the place it divides totalTokens by contextTokens and switch to a live-transcript token estimate (the Claude CLI session file size, or an explicit currentContextTokens field that the harness can populate from the last response usage).
  • SessionEntry.totalTokensFresh exists in the type definitions (dist/plugin-sdk/src/config/sessions/types.d.ts lines 278–283) and is meant to flag stale snapshots — verify the Dashboard respects it.

Workaround for affected users

  • Long Dashboard sessions are best treated as one-shot. Periodically capture anything important to workspace files (e.g. IDENTITY.md, USER.md, memory/*.md) so context loss isn't catastrophic.
  • Don't rely on /compact to summarize once the meter is at 100% — by then, it can't.

Filed as part of debugging a real session-loss this morning. Raw evidence and reasoning trail are available on request.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING