Skip to content

[Bug]: direct session can exceed configured contextWindow without timely compaction #50065

@ningfeemic-dev

Description

@ningfeemic-dev

Summary

Direct chat sessions can grow past the configured/effective context window (observed around 223k/200k) without timely compaction, eventually causing unstable behavior such as non-replies or broken command lanes.

Expected

  • Sessions nearing the active contextWindow should compact before crossing the limit.
  • compaction.mode = safeguard should prevent long-lived direct sessions from drifting beyond the configured token budget.

Actual

  • A direct session exceeded the apparent 200k window and reached roughly 223k/200k.
  • The session became unreliable: no reply / degraded behavior.
  • Another direct session later showed a cleared lane symptom and also needed reset.
  • Resetting the affected sessions restored normal behavior.

Environment

  • OpenClaw main agent
  • Telegram direct sessions (multi-account setup)
  • compaction.mode = safeguard
  • Legacy context engine path appears active

Notes

  • This does not appear to be a provider-token issue or bot token issue.
  • Account routing and messaging recovered after session reset, which suggests session state / compaction behavior rather than transport failure.
  • Runtime inspection suggests the fallback context window is 200000, but compaction did not reliably trigger before the session exceeded that threshold.

Why this matters

When compaction does not trigger in time, long-lived direct sessions can silently degrade and require manual reset, which is especially painful for always-on assistant accounts.

Possible directions

  • Re-check when safeguard compaction is triggered for direct sessions
  • Verify whether token estimation is undercounting until too late
  • Verify whether some direct-session paths bypass compaction or fail compaction silently
  • Consider earlier safety margins before the full context window is reached

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