Skip to content

Gateway broadcasts agent responses to all channels instead of respecting deliveryContext #51812

Description

@yuzheng969993

Issue: Gateway broadcasts agent responses to all channels instead of respecting deliveryContext

Description

When multiple chat channels (e.g., webchat and Feishu) are connected to the same agent instance (agent:main), the Gateway appears to broadcast agent responses to all active channels instead of delivering the response only to the channel that sent the original message.

Expected Behavior

Each session should have isolated message delivery:

  • User sends message via webchat → Agent responds to webchat only
  • User sends message via feishu → Agent responds to feishu only

The deliveryContext in session configuration should be respected:

{
  "sessionKey": "agent:main:feishu:direct:ou_xxx",
  "channel": "feishu",
  "deliveryContext": {
    "channel": "feishu",
    "to": "user:ou_xxx"
  }
}

Actual Behavior

Agent responses are being broadcast to all connected channels, causing:

  1. Duplicate messages appearing in both webchat and Feishu
  2. User confusion (seeing responses meant for other sessions)
  3. Broken conversation context (messages appear in wrong session)

Reproduction Steps

  1. Configure OpenClaw Gateway with multiple channels (e.g., webchat + Feishu)
  2. Connect to the same agent (agent:main) from both channels
  3. Send a message from webchat
  4. Observe: Response appears in both webchat AND Feishu

Environment

  • OpenClaw Version: 2026.3.13 (61d171a)
  • Node: v24.14.0
  • OS: Linux 6.6.87.2-microsoft-standard-WSL2 (x64)
  • Channels: webchat (built-in), Feishu (Lark)
  • Model: modelstudio/qwen3.5-plus

Session Configuration

Both sessions share agent:main but have separate deliveryContext:

Session 1 (webchat):

{
  "sessionKey": "agent:main:main",
  "channel": "webchat",
  "deliveryContext": { "channel": "webchat" }
}

Session 2 (feishu):

{
  "sessionKey": "agent:main:feishu:direct:ou_xxx",
  "channel": "feishu",
  "deliveryContext": {
    "channel": "feishu",
    "to": "user:ou_xxx"
  }
}

Impact

This issue breaks:

  • Multi-channel deployments where users expect channel-specific conversations
  • Privacy (messages intended for one channel leak to others)
  • User experience (confusing duplicate messages)

Workaround

Currently using delivery.mode: "none" for cron-triggered tasks to prevent duplicate notifications, but this doesn't solve the core issue for regular user messages.

Proposed Fix

The Gateway's message delivery logic should:

  1. Strictly respect session.deliveryContext.channel when routing responses
  2. Never broadcast to channels other than the one specified in deliveryContext
  3. Log delivery decisions for debugging (e.g., "Delivering to channel X, skipping Y")

Additional Context

This appears to be in the Gateway's response routing logic, not in agent configuration. Sessions are correctly isolated with separate deliveryContext, but the Gateway ignores this when delivering responses.


Labels: bug, gateway, multi-channel, message-routing
Priority: High (affects core functionality)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions