Skip to content

Webchat Heartbeat Message Incorrectly Delivered to Feishu #35300

@Yaemikoreal

Description

@Yaemikoreal

Bug type

Behavior bug (incorrect output/state without crash)

Summary

When OpenClaw's webchat heartbeat polling triggers an agent response, the system incorrectly sets the delivery context to the Feishu channel and attempts to deliver messages to heartbeat as a Feishu user ID, causing the Feishu API to return an invalid user ID error.

Steps to reproduce

  1. Configure multiple channels (webchat + feishu)
  2. Bind main agent to feishu channel via bindings config
  3. Webchat heartbeat polling sends a message with from: "heartbeat", provider: "webchat"
  4. Main agent responds to the heartbeat message
  5. System incorrectly sets deliveryContext.channel to "feishu"
  6. Message delivery fails and enters delivery-queue for retry loop

Expected behavior

  1. Webchat heartbeat messages should NOT trigger cross-channel delivery
  2. The heartbeat placeholder should be recognized and skipped for delivery
  3. deliveryContext.channel should follow the message origin channel, not be overwritten by agent bindings

Actual behavior

Feishu API returns error: Invalid ids: [heartbeat]. The message delivery fails and enters delivery-queue, causing retry loops on every gateway restart. Error log shows:

code: 99992360
msg: The request you send is not a valid {user_id} or not exists

OpenClaw version

2026.3.1

Operating system

Windows 11

Install method

npm global

Logs, screenshots, and evidence

Session state in sessions.json shows:

{
  "agent:main:main": {
    "origin": {
      "from": "heartbeat",
      "to": "heartbeat",
      "provider": "webchat"
    },
    "deliveryContext": {
      "channel": "feishu"  // Should be "webchat" or no delivery
    }
  }
}


Delivery queue entry:

{
  "to": "heartbeat",
  "accountId": "main",
  "sessionKey": "agent:main:feishu:direct:heartbeat",
  "text": "..."
}

Impact and severity

Affected: Users with multi-channel setup (webchat + feishu)
Severity: Medium (causes API errors and retry loops)
Frequency: 100% repro when heartbeat triggers agent response
Consequence: Gateway logs fill with errors, delivery-queue accumulates failed entries

Additional information

Root Cause: The deliveryContext inheritance logic incorrectly uses the agent's channel binding instead of the message origin channel.

Workaround: Disable or reduce heartbeat task frequency to avoid triggering this bug.

Suggested Fix:

  1. Heartbeat messages (from: "heartbeat") should be identified as system messages and not trigger message delivery
  2. deliveryContext should be derived from message origin (provider field), not from agent's channel bindings
  3. Add validation to prevent using placeholder IDs like "heartbeat" as real user IDs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions