From 2f44e86ef211c2102aaf5bec2db94a45ceeed2a3 Mon Sep 17 00:00:00 2001 From: viettranx Date: Fri, 27 Feb 2026 22:12:15 +0700 Subject: [PATCH] fix: Strip bot self-mention in Discord responses and remove AGENTS.md from summoning modal Discord: include sender's mention format in [From:] annotation so models use the correct user ID, and strip the bot's own @mention from message content to prevent the model from echoing it back. Summoning modal: remove AGENTS.md from progress list since backend only generates SOUL.md and IDENTITY.md. Co-Authored-By: Claude Opus 4.6 --- internal/channels/discord/discord.go | 7 ++++++- ui/web/src/pages/agents/summoning-modal.tsx | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/channels/discord/discord.go b/internal/channels/discord/discord.go index d84c1cb3..2f3cd8a4 100644 --- a/internal/channels/discord/discord.go +++ b/internal/channels/discord/discord.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log/slog" + "strings" "sync" "time" @@ -330,10 +331,14 @@ func (c *Channel) handleMessage(_ *discordgo.Session, m *discordgo.MessageCreate c.placeholders.Store(m.ID, placeholder.ID) } + // Strip bot @mention from content — it's just the trigger, not meaningful. + content = strings.ReplaceAll(content, "<@"+c.botUserID+">", "") + content = strings.TrimSpace(content) + // Build final content with group context. finalContent := content if peerKind == "group" { - annotated := fmt.Sprintf("[From: %s]\n%s", senderName, content) + annotated := fmt.Sprintf("[From: %s (<@%s>)]\n%s", senderName, senderID, content) if c.historyLimit > 0 { finalContent = c.groupHistory.BuildContext(channelID, annotated, c.historyLimit) } else { diff --git a/ui/web/src/pages/agents/summoning-modal.tsx b/ui/web/src/pages/agents/summoning-modal.tsx index b127a062..5cb5c287 100644 --- a/ui/web/src/pages/agents/summoning-modal.tsx +++ b/ui/web/src/pages/agents/summoning-modal.tsx @@ -21,7 +21,6 @@ interface SummoningModalProps { const SUMMONING_FILES = [ { name: "SOUL.md", label: "Soul & Personality" }, { name: "IDENTITY.md", label: "Identity Card" }, - { name: "AGENTS.md", label: "Operating Instructions" }, ]; export function SummoningModal({