openclaw - 💡(How to fix) Fix Telegram main session can wedge after long-running context and stop replying [2 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#51014Fetched 2026-04-08 01:05:33
View on GitHub
Comments
2
Participants
2
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
commented ×2

Error Message

  • emit a fallback error reply to the Telegram user
RAW_BUFFERClick to expand / collapse

What happened

An OpenClaw instance running on Telegram stopped replying even though the Telegram webhook path itself remained healthy.

In this case:

  • Telegram webhook stayed registered and healthy
  • local webhook listener stayed up
  • the gateway service stayed running
  • incoming Telegram messages appeared to reach OpenClaw
  • but no final reply was sent back to Telegram

A gateway restart temporarily restored the runtime, which suggests the failure is in the session/run pipeline rather than Telegram delivery.

Environment

  • OpenClaw: 2026.3.13
  • Installed from npm (openclaw@latest also resolves to 2026.3.13)
  • Channel: Telegram webhook mode
  • Runtime observed on Linux via systemd user service

Observed symptoms

The active Telegram main session had grown very large:

  • contextTokens=200000
  • totalTokens=177106
  • cacheRead=176768
  • compactionCount=0

The gateway showed signs of long-running session processing and timeout during reply generation / maintenance:

  • embedded run timeout: timeoutMs=600000
  • timed out during compaction
  • AbortError: Unsubscribed during compaction
  • typing TTL reached (2m); stopping typing indicator

At the same time, upstream responses traffic also showed instability:

  • reverse proxy logs contained aborting with incomplete response
  • reverse proxy logs contained context canceled

Why this looks like an OpenClaw issue

The Telegram integration itself appeared healthy:

  • webhook remained registered with Telegram
  • pending_update_count was 0
  • local listener was still bound on the configured webhook port
  • reverse proxy routing to the local webhook path was correct

So the failure mode seems to be:

  1. Telegram message arrives successfully
  2. OpenClaw tries to process it inside a very large long-lived main session
  3. the run and/or compaction path times out
  4. no final Telegram reply is emitted

Suspected trigger

This Telegram main session had been used as a long-running supervisor/orchestrator session that spawned other work over time. Once the session became very large, compaction apparently failed to complete, and reply generation wedged.

The concerning part is not just that a huge session is slow, but that the bot can enter a state where Telegram still looks healthy externally while replies silently stop.

Expected behavior

Even if a Telegram session becomes too large or compaction fails, OpenClaw should ideally do one of the following instead of silently ceasing replies:

  • recover by forcing a fresh session / hard compaction
  • emit a fallback error reply to the Telegram user
  • surface a clearer channel-specific failure state
  • avoid wedging the main Telegram session indefinitely

Actual behavior

The Telegram bot stopped replying until the gateway service was restarted.

Potentially relevant data points

From the session metadata:

  • large system prompt and tool schema overhead
  • main Telegram session stuck near large context limits
  • no successful compaction despite high token load

From service/runtime behavior:

  • gateway remained active
  • webhook listener remained active
  • restart brought the runtime back up cleanly

Request

Could you investigate whether there is a failure mode in the Telegram main-session pipeline where oversized sessions + compaction timeout + upstream response interruption can leave the channel apparently healthy but unable to send replies?

It would also help to know whether there is a recommended built-in way to rotate/reset a wedged Telegram main session without restarting the whole gateway.

extent analysis

Fix Plan

To address the issue of oversized sessions causing the Telegram bot to stop replying, we can implement the following steps:

  • Implement session size limits: Introduce a check to limit the size of the Telegram main session. When the session size exceeds a certain threshold, force a fresh session or hard compaction.
  • Handle compaction timeouts: Catch compaction timeouts and recover by forcing a fresh session or hard compaction.
  • Emit fallback error replies: When reply generation fails due to session size or compaction issues, emit a fallback error reply to the Telegram user.
  • Surface channel-specific failure states: Introduce a mechanism to surface clearer channel-specific failure states when the Telegram bot is unable to send replies.

Example code snippet to implement session size limits and handle compaction timeouts:

const MAX_SESSION_SIZE = 100000; // adjust this value based on performance requirements

// Check session size and force a fresh session or hard compaction if exceeded
if (session.contextTokens >= MAX_SESSION_SIZE) {
  // Force a fresh session or hard compaction
  session = await createFreshSession();
}

// Catch compaction timeouts and recover
try {
  await compactSession(session);
} catch (error) {
  if (error instanceof TimeoutError) {
    // Recover by forcing a fresh session or hard compaction
    session = await createFreshSession();
  } else {
    throw error;
  }
}

Verification

To verify that the fix worked, monitor the Telegram bot's behavior and check for the following:

  • The bot responds to messages even when the session size is large.
  • The bot recovers from compaction timeouts and continues to respond to messages.
  • Fallback error replies are emitted when reply generation fails due to session size or compaction issues.
  • Channel-specific failure states are surfaced when the bot is unable to send replies.

Extra Tips

To prevent regressions, consider implementing the following:

  • Regularly monitor session sizes and adjust the MAX_SESSION_SIZE threshold as needed.
  • Implement a mechanism to detect and prevent oversized sessions from forming in the first place.
  • Consider introducing a queueing mechanism to handle incoming messages when the session is being compacted or recovered.

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…

FAQ

Expected behavior

Even if a Telegram session becomes too large or compaction fails, OpenClaw should ideally do one of the following instead of silently ceasing replies:

  • recover by forcing a fresh session / hard compaction
  • emit a fallback error reply to the Telegram user
  • surface a clearer channel-specific failure state
  • avoid wedging the main Telegram session indefinitely

Still need to ship something?

×6

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

Back to top recommendations

TRENDING