Skip to content

fix(dingtalk): serialize inbound messages per chat session#17366

Open
spike2204 wants to merge 1 commit into
NousResearch:mainfrom
spike2204:fix/dingtalk-inbound-queue
Open

fix(dingtalk): serialize inbound messages per chat session#17366
spike2204 wants to merge 1 commit into
NousResearch:mainfrom
spike2204:fix/dingtalk-inbound-queue

Conversation

@spike2204

Copy link
Copy Markdown

Summary

When a user sends multiple messages rapidly (or sends text + file in quick succession), the adapter processes them concurrently, causing race conditions in AI Card lifecycle management — cards from message N clobber cards from message N+1.

Changes

  • Add _enqueue_inbound() — per-chat asyncio.Queue with configurable max depth (default 32)
  • Add _sweep_session_queues() — periodic cleanup of idle session queues (>30min)
  • Route all _on_message() calls through the per-chat queue so messages within the same conversation are processed sequentially while different conversations remain concurrent

Related

Part of the DingTalk adapter enhancement series — see #12769 for the umbrella PR.

…ate agent turns

When the agent is busy processing a message, a second inbound message
for the same chat spawns a parallel turn, producing duplicate or
interleaved replies.

- Add _enqueue_inbound() / _sweep_session_queues() — promise-chain
  queue per chat that serializes message processing
- Send a random busy-ACK phrase for queued messages so the user knows
  their message was received
- Queue entries auto-expire after 5 minutes (matches openclaw-connector
  core/message-handler.ts:92)
- Sweeper task runs every 60s to clean stale queue entries
- Proper cleanup on disconnect (cancel pending tasks) to #
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/dingtalk DingTalk adapter labels Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/dingtalk DingTalk adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants