openclaw - 💡(How to fix) Fix Session health check: auto-clear stuck sessions after prolonged unresponsiveness [1 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#58580Fetched 2026-04-08 02:00:41
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
commented ×1

Root Cause

In a real incident, 20+ Telegram messages went unanswered over several hours because the session was stuck in a failed state. The gateway had no mechanism to detect or recover from this.

Fix Action

Fix / Workaround

Current Workaround

Code Example

rm ~/.openclaw/agents/main/sessions/sessions.json && openclaw daemon restart
RAW_BUFFERClick to expand / collapse

Problem

After gateway crashes and restarts, sessions can accumulate corrupted state — pinned to a broken model override, bloated token counts (280k+), or stale context. The session appears \alive\ but silently fails on every incoming message.

In a real incident, 20+ Telegram messages went unanswered over several hours because the session was stuck in a failed state. The gateway had no mechanism to detect or recover from this.

Expected Behavior

If a session hasn't responded successfully in N minutes (e.g. 30) despite receiving messages, the gateway should:

  1. Log a warning
  2. Auto-clear the stuck session
  3. Start a fresh session for that channel

Current Workaround

Manual nuclear option:

rm ~/.openclaw/agents/main/sessions/sessions.json && openclaw daemon restart

This kills ALL sessions, not just the stuck one.

Impact

Primary cause of extended user-facing downtime. The gateway was running, Telegram was connected, but the session layer was silently broken. No alerts, no recovery, no indication anything was wrong except messages disappearing into the void.

extent analysis

TL;DR

Implement a mechanism to detect and auto-clear stuck sessions after a specified period of inactivity or failure.

Guidance

  • Identify the condition for a session to be considered "stuck" (e.g., no successful responses within a certain time frame) and implement a check for this condition.
  • Develop a logging mechanism to warn when a session is detected as stuck.
  • Create a function to auto-clear stuck sessions and start a fresh session for the affected channel.
  • Consider implementing a more targeted workaround than the current "nuclear option" to avoid clearing all sessions.

Example

# Pseudo-code example of a function to check for stuck sessions
def check_stuck_sessions(sessions, timeout_minutes):
    for session in sessions:
        if session.last_successful_response < (datetime.now() - timedelta(minutes=timeout_minutes)):
            # Log warning and auto-clear session
            logging.warning(f"Session {session.id} is stuck. Clearing session.")
            clear_session(session)
            start_fresh_session(session.channel)

Notes

The current workaround has significant limitations, as it clears all sessions. A more targeted approach is needed to minimize disruption.

Recommendation

Apply a workaround by implementing a session monitoring and auto-clearing mechanism, as this will allow for more targeted and less disruptive recovery from stuck sessions.

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