-
-
Notifications
You must be signed in to change notification settings - Fork 69.4k
Discord: parallel message handling for multi-agent setups #1295
Description
Problem
When multiple Discord channels are bound to different agents, messages are processed sequentially rather than in parallel. This causes significant delays in multi-agent setups.
Observed behavior
Sending messages to 3 different Discord channels (each bound to a different agent) results in:
[EventQueue] Listener DiscordMessageListener timed out after 30000ms for event MESSAGE_CREATE
[discord] Slow listener detected: DiscordMessageListener took 56.2 seconds for event MESSAGE_CREATE
[discord] Slow listener detected: DiscordMessageListener took 58.8 seconds for event MESSAGE_CREATE
Each message waits for the previous one to complete before processing begins.
Root cause
The Discord listener in src/discord/monitor/listeners.ts awaits the handler:
async handle(data: DiscordMessageEvent) {
// ...
await this.handler(data, client); // ← blocks the event queue
}This is inherited from Carbon's listener pattern.
Comparison with WhatsApp
WhatsApp uses fire-and-forget (void task), allowing parallel processing across different sessions/groups. Different WhatsApp groups process simultaneously without blocking.
Expected behavior
Messages to different channels/sessions should process in parallel. Only messages to the same session should be serialized (to maintain ordering within a conversation).
Suggested fix
Either:
- Spawn handlers without awaiting for different session keys
- Add a per-session queue while allowing cross-session parallelism
- Make this configurable (e.g.,
discord.parallelSessions: true)
Use case
Multi-agent Discord server with dedicated channels per agent (e.g., #research, #coding, #admin). Users expect snappy responses from all agents simultaneously, not sequential processing.
Environment
- Clawdbot version: 2026.1.17-1
- Discord channels: 4 (bound to 4 different agents)
- Models: mix of Opus 4.5, Sonnet 4, Haiku 3.5