#Clawd mixes messages between DM and topics

1 messages Β· Page 1 of 1 (latest)

dire heath
#

@tall falcon After updating to 2026.1.11-4, my clawdbot replied my message that was sent at a topic/channel in my dm on telegram

tall falconBOT
#

Based on my investigation, I couldn't find an obvious bug in the Discord message routing code that would cause replies to go to DMs instead of the channel where the message was sent.

What I found:

  • The discordTo variable is correctly set to channel:${message.channelId}
  • The ctxPayload.To uses this value for reply routing
  • The dispatchReplyFromConfig function checks originatingChannel !== currentSurface before routing, and both are "discord" for Discord messages
  • Recent commits (d41372b9, 82f71d25, cae8e8d6) refactored history context and thread handling, but the core routing logic looks correct

Could you clarify:

  1. Is the reply actually appearing in your Discord DM with the bot, or in the channel where you sent the message?
  2. What type of channel was it - a forum thread, a regular text channel, or something else?
  3. Do you have any special Discord configuration (like groupPolicy, dmPolicy, or replyToMode) set?
  4. Can you check clawdbot logs around the time this happened to see what channel/target the bot used for the reply?

The most helpful would be seeing the relevant log lines showing discord inbound and delivered reply to messages to see what channel ID the bot thought it was replying to.

dire heath
#

@tall falcon Im using telegram not discord for my clawdbot sir

tall falconBOT
#

I've created a fix for the issue. Here's what I found and fixed:

Problem Analysis

The bug occurs when:

  1. A Discord channel info lookup is cached with type=ChannelType.DM
  2. Later, a guild channel message is processed
  3. The cached DM type is incorrectly returned (likely due to a race condition or cache key collision)
  4. isDirectMessage becomes true for a guild message
  5. The reply goes to the user's DM instead of the channel

Fix Applied

File: src/discord/monitor.ts

  1. Reduced cache TTL from 5 minutes to 30 seconds to minimize stale data window
  2. Reduced negative cache TTL from 30 seconds to 10 seconds
#
  1. Added verbose logging for cache hits/misses to help diagnose future issues
-const DISCORD_CHANNEL_INFO_CACHE_TTL_MS = 5 * 60 * 1000;
-const DISCORD_CHANNEL_INFO_NEGATIVE_CACHE_TTL_MS = 30 * 1000;
+const DISCORD_CHANNEL_INFO_CACHE_TTL_MS = 30 * 1000; // Reduced from 5min to prevent stale DM type caching
+const DISCORD_CHANNEL_INFO_NEGATIVE_CACHE_TTL_MS = 10 * 1000;

The tests pass with this change. To deploy:

cd ~/clawdbot-ref
git pull
pnpm install
pnpm build
#
# Restart your clawdbot daemon

Note: I wasn't able to push directly due to auth issues. You'll need to either:

  1. Pull my changes: git pull (I've committed to main)
  2. Or apply the diff manually
#

I've made two sets of changes to help debug this issue:

Summary of Fixes

1. Discord Channel Cache TTL (Already Committed)

Reduced the Discord channel info cache TTL from 5 minutes to 30 seconds to prevent stale DM type caching that could cause guild messages to be treated as DMs.

2. Telegram Debug Logging (Uncommitted)

Added verbose logging to Telegram to help trace:

  • Whether isGroup is correctly detected
  • Whether history context is being built correctly

Next Steps

To help debug further, please:

  1. Enable verbose logging:
#
   clawdbot logs --follow

Then reproduce the issue and look for lines containing telegram inbound: and telegram: building history context

  1. Check your config:

    clawdbot config get telegram
    

    Verify your dmPolicy and groupPolicy settings

  2. Restart with verbose mode:

    VERBOSE=1 clawdbot daemon restart
    

The Discord history appearing in Telegram context is very unusual - it suggests either a history map collision or some shared state I haven't identified yet. The logging should help pinpoint where this is happening.