Summary
session.sendPolicy deny rules have no effect on WhatsApp auto-reply responses. The auto-reply delivery pipeline (on-message.ts → process-message.ts → deliverWebReply) never calls resolveSendPolicy, so deny rules intended to suppress replies to specific DM sessions are silently ignored.
Related issues
All three issues stem from sendPolicy only being enforced in commands-core.ts and gateway/server-methods/agent.ts, while other outbound paths bypass it.
Reproduction
- Configure sendPolicy to deny WhatsApp DM replies except self-chat:
"session": {
"sendPolicy": {
"rules": [
{ "action": "allow", "match": { "keyPrefix": "agent:main:whatsapp:direct:+44XXXXXXXXXX" } },
{ "action": "allow", "match": { "channel": "whatsapp", "chatType": "group" } },
{ "action": "deny", "match": { "keyPrefix": "agent:main:whatsapp:direct:" } }
],
"default": "allow"
}
}
- Set
dmPolicy: "open" with allowFrom: ["*"] so messages are ingested
- Receive a DM from another WhatsApp contact
- Expected: message is ingested but no reply is sent (deny rule matches)
- Actual: assistant replies to the other contact, ignoring the deny rule
Root cause
resolveSendPolicy() is only called from:
src/auto-reply/reply/commands-core.ts (text command processing)
src/gateway/server-methods/agent.ts (gateway-mediated sends)
The WhatsApp auto-reply flow does not check it:
src/web/auto-reply/monitor/on-message.ts — DM branch (~line 145) has no reply gating (unlike the group branch which has applyGroupGating)
src/web/auto-reply/monitor/process-message.ts → deliverWebReply — no resolveSendPolicy call
Impact
Users cannot configure a "see but don't reply" mode for non-self DMs. The assistant responds to incoming DMs from other contacts even when sendPolicy explicitly denies them. The only workaround is dmPolicy: "allowlist" with empty allowFrom, which blocks messages at the inbound access-control layer entirely (no ingestion, no context).
Suggested fix
Add a resolveSendPolicy check in the DM branch of on-message.ts (or in process-message.ts before dispatching the reply). If the policy resolves to "deny", skip the reply but still allow the message to be ingested for context — mirroring how group mention-gating stores un-mentioned messages in history without replying.
Summary
session.sendPolicydeny rules have no effect on WhatsApp auto-reply responses. The auto-reply delivery pipeline (on-message.ts→process-message.ts→deliverWebReply) never callsresolveSendPolicy, so deny rules intended to suppress replies to specific DM sessions are silently ignored.Related issues
message sendAll three issues stem from
sendPolicyonly being enforced incommands-core.tsandgateway/server-methods/agent.ts, while other outbound paths bypass it.Reproduction
dmPolicy: "open"withallowFrom: ["*"]so messages are ingestedRoot cause
resolveSendPolicy()is only called from:src/auto-reply/reply/commands-core.ts(text command processing)src/gateway/server-methods/agent.ts(gateway-mediated sends)The WhatsApp auto-reply flow does not check it:
src/web/auto-reply/monitor/on-message.ts— DM branch (~line 145) has no reply gating (unlike the group branch which hasapplyGroupGating)src/web/auto-reply/monitor/process-message.ts→deliverWebReply— noresolveSendPolicycallImpact
Users cannot configure a "see but don't reply" mode for non-self DMs. The assistant responds to incoming DMs from other contacts even when sendPolicy explicitly denies them. The only workaround is
dmPolicy: "allowlist"with emptyallowFrom, which blocks messages at the inbound access-control layer entirely (no ingestion, no context).Suggested fix
Add a
resolveSendPolicycheck in the DM branch ofon-message.ts(or inprocess-message.tsbefore dispatching the reply). If the policy resolves to"deny", skip the reply but still allow the message to be ingested for context — mirroring how group mention-gating stores un-mentioned messages in history without replying.