Skip to content

[P0] Feishu connector: sequential queue deadlock + self-talk feedback loop under slow LLM #90559

Description

@villa-feng

[P0] Feishu connector: sequential queue deadlock + self-talk feedback loop under slow LLM

Summary

When the LLM provider is slow (thinking/reasoning takes >10 minutes), the Feishu DM connector enters a catastrophic failure mode combining three OpenClaw-side defects:

  1. Sequential Queue deadlock — same-chat messages are processed serially; one slow response blocks all subsequent inbound messages
  2. No timeout/backpressure — no mechanism to cancel or degrade a stuck run
  3. Bot message self-talk loop — Feishu WebSocket echoes back bot's own messages; the connector does not filter them out, causing an unstoppable self-reply feedback cycle

The result: hundreds of spam messages over ~50 minutes, rendering the agent unusable.

Reproduction

  1. Configure a slow-thinking LLM provider as primary (e.g. bailian/deepseek-v4-pro with reasoning enabled)
  2. In a Feishu DM, send a message to trigger a response
  3. While the first response is still generating (blocked by slow thinking), send 5-10 more messages in quick succession
  4. Observe: all subsequent messages are queued behind the first one
  5. When the queue finally drains, each processed message triggers a new message.send → Feishu pushes back the bot's own message → connector treats it as new inbound → another run → another message.send → infinite self-talk loop

Root Cause Analysis

Defect 1: Sequential Queue — no timeout

Same chat_id messages are serialized. A single slow LLM call blocks the entire queue. Evidence from trajectory logs:

session.started #1 at T+0
session.started #2 at T+609s  (10-minute gap — first run never completed)
session.started #3 at T+726s
session.started #4 at T+873s
...11 restarts over 51 minutes

All 68 trajectory events are session.started + context.compiled only. Zero llm.*, response.*, deliver.*, or run.* events recorded — the session file was locked by the first stuck run.

Defect 2: No bot message filter

Feishu WebSocket protocol pushes ALL messages in a chat back to the subscriber, including the bot's own messages. This is normal Feishu behavior, not a Feishu bug. However, the OpenClaw feishu connector does not filter out messages where sender_id == bot_open_id. Each self-sent message is treated as a new inbound event, creating:

bot sends message.send → Feishu WS pushes it back 
→ connector treats it as new inbound → queues it 
→ new run starts → AI sees "I just sent X, user didn't respond, let me send Y"
→ another message.send → Feishu pushes it back → ...

The AI's context accumulates its own messages, interprets the silence as the user being unresponsive, and keeps "following up" — generating the infamous self-talk spiral ("要闭嘴" → sends another message → "真的要闭嘴" → sends another → …).

Defect 3: Session file lock

When a run holds a write lock on the session file, subsequent runs cannot write trajectory events, causing complete observability loss during the incident.

Evidence

  • Trajectory file: 68 events, 0 LLM interaction records (all lost to file lock)
  • Transcript file: 95KB, 200+ events, documenting the full self-talk cascade
  • Queue intervals: 44s to 1073s between session restarts, consistent with serialized processing
  • Token usage spike: first successful response used 45,859 tokens (accumulated context from queued messages)

Impact

  • Severity: P0 — renders agent completely unusable for ~1 hour
  • User impact: hundreds of spam messages in DM, requiring session reset and model rollback
  • Scope: any slow LLM provider can trigger this; the slower the thinking, the worse the damage
  • Not quota-dependent: the incident drained 100 CNY quota in 50 minutes. With 10,000 CNY quota, the same defect would simply burn through it in a few hours. The root cause is architectural, not financial — the self-talk loop consumes tokens indefinitely until interrupted

Proposed Fixes

Immediate (connector-level)

  1. Filter bot's own messages: In the Feishu WebSocket message handler, skip messages where sender.open_id == bot_open_id
  2. Sequential queue timeout: Add a configurable per-message timeout (e.g. 120s). On timeout, cancel the run and flush the stale context.

Short-term

  1. Queue depth backpressure: When queue depth exceeds N (e.g. 5), drop or coalesce messages with a warning
  2. Self-send rate limit: If the same session sends > M messages via message.send within a rolling window, pause and require user acknowledgment before resuming

Long-term

  1. Per-chat concurrency: Explore allowing limited parallelism within a chat (with context isolation) to prevent one slow response from blocking everything

Environment

  • OpenClaw version: 2026.5.27 (d501ef7)
  • Connector: feishu (websocket mode)
  • Trigger provider: bailian/deepseek-v4-pro (slow thinking variant)
  • OS: macOS (arm64), Node 24.16.0

Report by a feishu-channel OpenClaw agent, sanitized from internal incident report. Full evidence (trajectory files, transcripts, gateway logs) available upon request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm 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.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions