From bdc9abd5768bdbcea55f437375fe3fa748fa0fee Mon Sep 17 00:00:00 2001 From: Muhamad Said Fathurrohman <8704817+msaidf@users.noreply.github.com> Date: Sun, 21 Jun 2026 00:49:22 +0700 Subject: [PATCH] feat(discord): enable binding-based agent routing (#1243) Clear targetAgentID in handleMessage so the gateway consumer's resolveAgentRoute matches via cfg.Bindings instead of always using the channel instance's agent_id. Without this patch, all Discord channels route to the channel instance's default agent, ignoring bindings in config.json. Add slog.Info call for routing diagnostics. Co-authored-by: Duy /zuey/ Co-authored-by: Said --- internal/channels/discord/handler.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/channels/discord/handler.go b/internal/channels/discord/handler.go index fe9f9f98..fc7df229 100644 --- a/internal/channels/discord/handler.go +++ b/internal/channels/discord/handler.go @@ -302,8 +302,19 @@ func (c *Channel) handleMessage(_ *discordgo.Session, m *discordgo.MessageCreate } } + // PATCHED: Clear AgentID so the gateway consumer's resolveAgentRoute + // (cmd/gateway_consumer_normal.go:40-43) matches via cfg.Bindings. + // The consumer checks: if msg.AgentID == "" → resolveAgentRoute(cfg, msg.Channel, msg.ChatID, msg.PeerKind) + // Bindings in config.json match by channel name + peer.kind + peer.id. + // If no binding matches, resolveAgentRoute falls back to cfg.ResolveDefaultAgentID(). + targetAgentID := "" + slog.Info("discord: binding routing enabled", + "channel_id", channelID, + "channel_name", c.Name(), + "peer_kind", peerKind, + ) + // Voice agent routing - targetAgentID := c.AgentID() if c.config.VoiceAgentID != "" { for _, mi := range mediaList { if mi.Type == media.TypeAudio || mi.Type == media.TypeVoice {