Skip to content

Discord channel sessions bypass compaction, causing context overflow #11224

@henritheowl

Description

@henritheowl

OpenClaw Bug: Discord Channel Sessions Bypass Compaction

Severity: High
Discovered: 2026-02-07
Version: OpenClaw 2026.2.6-3 (85ed6c7)

Summary

Discord channel sessions accumulate tokens indefinitely, ignoring contextTokens limit and compaction settings. Eventually causes context overflow errors.

Expected Behavior

With config:

{
  "contextTokens": 50000,
  "compaction": {
    "mode": "default",
    "maxHistoryShare": 0.5
  }
}

All sessions should:

  • Send max ~50k tokens of history to the model
  • Trigger compaction when history exceeds 25k tokens (50% of 50k)
  • Never overflow the model's 200k context limit

Actual Behavior

Discord channel sessions grow unbounded:

Session Type Total Tokens Status
Telegram DM 63k ✓ Compaction works
Cron sessions ~25k ✓ Compaction works
Discord #chat 162k ⚠️ No compaction
Discord #samantha-feed 155k ⚠️ No compaction

Discord #chat eventually hit 211k tokens, causing:

400 {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 211803 tokens > 200000 maximum"}}

Impact

  • Silent failure with "typing..." indicator stuck
  • User waits 10+ minutes with no response
  • Requires manual session reset via /new or transcript deletion
  • Recurring issue as all Discord channel sessions trend toward overflow

Steps to Reproduce

  1. Configure contextTokens: 50000 and compaction.mode: default
  2. Use OpenClaw via Discord channels for several days
  3. Run openclaw sessions list --json | jq '.sessions[] | {key, totalTokens}'
  4. Observe Discord channel sessions far exceeding contextTokens limit

Workaround

Created session-monitor.py cron that:

  • Checks session token counts every 15 min
  • Alerts at 80% of 200k limit
  • Auto-prunes transcripts at 95%

Environment

  • OpenClaw 2026.2.6-3 (85ed6c7)
  • macOS Darwin 25.2.0 (arm64)
  • Node v25.5.0
  • Model: anthropic/claude-opus-4-5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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