openclaw - 💡(How to fix) Fix lossless-claw contextThreshold does not adapt to actual model context window after fallback

Official PRs (…)
ON THIS PAGE

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…
RAW_BUFFERClick to expand / collapse

Bug Description

When an agent session falls back from a small-context model (e.g. glm-5.1, 200K) to a large-context model (e.g. deepseek-v4-pro, 1M), the lossless-claw plugin continues to use the original model's contextWindow to calculate the compression threshold, rather than dynamically adapting to the currently active model.

Impact

  • Premature compression: With contextThreshold: 0.75, a 200K model triggers LCM compression at 150K tokens
  • Context loss: Historical conversation is summarized/lost before the session falls back to a larger model
  • User-visible interruption: The combination of premature compression + fallback chain causes conversations to appear "cut off" around 190K tokens
  • Cascading failure: After compression on the small model still fails, the fallback chain tries multiple small-window models (all fail) before reaching a large-window model, by which time context is already lost

Reproduction

  1. Configure an agent without its own model field, inheriting global default zai/glm-5.1 (contextWindow: 200K)
  2. Include deepseek/deepseek-v4-pro (contextWindow: 1M) in the fallback chain
  3. Have a long conversation that grows past 150K tokens
  4. Observe: LCM compression triggers (based on 200K × 0.75 = 150K threshold), then model fails, falls back through chain to deepseek
  5. Result: conversation history is compressed/lost despite now having a 1M context window

Expected Behavior

lossless-claw should dynamically read the currently active model's contextWindow to calculate the threshold, not the originally configured primary model's window. When a session is running on a 1M context model, the threshold should be 750K, not 150K.

Environment

  • OpenClaw: 2026.5.20
  • lossless-claw config: contextThreshold: 0.75
  • Observed on agent tax-invoice-analyst session

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