Skip to content

[Bug/Feature Request] Message queue blocks user messages during long-running tasks #7698

@EisonMe

Description

@EisonMe

[Bug/Feature Request] Message queue blocks user messages during long-running tasks

1. Problem Description

When the Agent is processing a message (such as heartbeat checks or system events), new user messages are queued and experience significant delays. This creates a poor user experience where user interactions are blocked by background system operations.

Real-world case: User messages experienced an 11-minute delay before being processed due to system events triggered by WhatsApp gateway disconnection.

2. Steps to Reproduce

  1. Agent is performing heartbeat checks
  2. WhatsApp gateway disconnects simultaneously, triggering system events
  3. User sends a message via Telegram
  4. Message gets queued until previous processing completes
  5. User experiences significant delay in receiving response

3. Root Cause Analysis

Serial Message Processing

  • Messages are processed sequentially - one message must complete before the next can be processed
  • No priority mechanism exists - user messages and system events are treated equally
  • No timeout interruption mechanism - even if a task gets stuck, it cannot be interrupted by new messages

Current Architecture Limitations

  • Single-threaded message handling creates bottlenecks
  • System events (like disconnection notifications) can block user-facing operations
  • No differentiation between time-sensitive user messages and background system tasks

4. Suggested Solutions

Priority Queue Implementation

  • Priority levels: Direct user messages > System events > Heartbeat checks
  • User interactions should always have the highest priority

Asynchronous System Event Handling

  • System events (like disconnection notifications) should not block user messages
  • Move non-critical system events to background processing

Timeout Mechanism

  • Implement timeout for individual message processing (e.g., X seconds)
  • Allow long-running tasks to be interrupted or moved to background
  • Provide feedback to users when tasks are taking longer than expected

Parallel Processing

  • Enable concurrent processing of lightweight messages
  • Implement worker pools for different message types
  • At minimum, allow multiple user messages to be processed simultaneously

5. Environment Information

  • OpenClaw version: 2026.2.1
  • OS: WSL2 Ubuntu on Windows
  • Channels: Telegram + WhatsApp
  • Impact: Critical - affects user experience and system responsiveness

6. Additional Context

This issue significantly impacts user experience, especially in scenarios where:

  • Multiple channels are active simultaneously
  • System events occur during peak user activity
  • Background maintenance tasks overlap with user interactions

The current behavior makes the system feel unresponsive and may cause users to believe the agent is not functioning correctly.

7. Acceptance Criteria

  • User messages are processed within 5 seconds regardless of background tasks
  • System events do not block user message processing
  • Priority queue correctly prioritizes user messages over system events
  • Timeout mechanism prevents indefinite blocking
  • Parallel processing handles concurrent user messages efficiently
  • System provides feedback when tasks are running longer than expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions