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/ <duy@wearetopgroup.com>
Co-authored-by: Said <msaidf@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-06-21 00:49:22 +07:00
1 parent cedd6673c4
commit bdc9abd576
1 file changed
+12 -1
+12 -1
View File
@@ -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 {