Skip to content

Session hangs indefinitely when compaction times out, causing repeated duplicate message sends #43661

Description

@thedanchez

Bug Report

Summary

When a session context becomes large enough to trigger compaction, and that compaction process times out, the agent enters a silent failure loop. Each timeout (~10 min) triggers a delivery retry that resends the same message to the user repeatedly — with no recovery, no fallback, and no way for the session to self-resolve.

Steps to Reproduce

  1. Send a large message to the agent (e.g. a long X/Twitter post or paste-heavy content)
  2. This bloats the session context enough to trigger compaction
  3. Compaction begins but hangs/times out (embedded run timeout: timed out during compaction)
  4. Every ~10 minutes, the timed-out run retries delivery — sending the same message again

Observed Behavior

  • Repeated embedded run timeout: timed out during compaction entries in logs, spaced ~10 minutes apart
  • Each timeout triggers a sendMessage to the user with the same content (4x in this case)
  • One final send attempt fails with 400: Bad Request: message is too long (Telegram limit hit)
  • Agent is completely unresponsive during this entire period
  • Only resolution was a manual pm2 reload

Relevant Log Excerpts

2026-03-12T03:35:13.596Z [agent/embedded] embedded run timeout: runId=... timeoutMs=600000
2026-03-12T03:35:13.599Z [agent/embedded] using current snapshot: timed out during compaction
2026-03-12T03:35:13.880Z [telegram] sendMessage ok chat=... message=579

2026-03-12T03:45:15.075Z [agent/embedded] embedded run timeout: runId=... timeoutMs=600000
2026-03-12T03:45:15.078Z [agent/embedded] using current snapshot: timed out during compaction
2026-03-12T03:45:16.385Z [telegram] sendMessage ok chat=... message=580

2026-03-12T03:55:17.499Z [agent/embedded] embedded run timeout: runId=... timeoutMs=600000
2026-03-12T03:55:17.503Z [agent/embedded] using current snapshot: timed out during compaction
2026-03-12T03:55:18.827Z [telegram] sendMessage ok chat=... message=582

2026-03-12T04:05:17.739Z [agent/embedded] embedded run timeout: runId=... timeoutMs=600000
2026-03-12T04:05:17.743Z [agent/embedded] using current snapshot: timed out during compaction

2026-03-12T04:08:51.252Z [telegram] message failed: Call to 'sendMessage' failed! (400: Bad Request: message is too long)
2026-03-12T04:08:51.256Z [delivery-recovery] Retry failed for delivery ...: Call to 'sendMessage' failed! (400: Bad Request: message is too long)

Expected Behavior

  • Compaction timeout should trigger a clean failure path, not a retry loop
  • If compaction fails, the agent should surface an error to the user (once), not retry the same send repeatedly
  • The session should either recover gracefully or terminate cleanly, not hang for 30+ minutes requiring manual intervention

Environment

  • OpenClaw (self-hosted, pm2-managed)
  • Channel: Telegram
  • Trigger: Large inbound message (external content paste)

Impact

  • Agent unresponsive for 30+ minutes
  • User receives 4 identical messages
  • Manual restart required to recover

Metadata

Metadata

Assignees

Labels

P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions