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:
- Duplicate messages appearing in both webchat and Feishu
- User confusion (seeing responses meant for other sessions)
- Broken conversation context (messages appear in wrong session)
Reproduction Steps
- Configure OpenClaw Gateway with multiple channels (e.g., webchat + Feishu)
- Connect to the same agent (
agent:main) from both channels
- Send a message from webchat
- 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:
- Strictly respect
session.deliveryContext.channel when routing responses
- Never broadcast to channels other than the one specified in
deliveryContext
- 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)
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:
The
deliveryContextin 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:
Reproduction Steps
agent:main) from both channelsEnvironment
Session Configuration
Both sessions share
agent:mainbut have separatedeliveryContext: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:
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:
session.deliveryContext.channelwhen routing responsesdeliveryContextAdditional 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-routingPriority: High (affects core functionality)