From bdb1b238a1f1fd7c795af4c66d5a54a4c5b036b1 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 19 Mar 2026 22:45:02 +0800 Subject: [PATCH] feat(agent): add Final field to outbound messages --- pkg/agent/loop.go | 2 ++ pkg/agent/loop_mcp.go | 2 +- pkg/bus/types.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index edb0994c2..6501ef7c7 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -193,6 +193,7 @@ func registerSharedTools( Channel: channel, ChatID: chatID, Content: content, + Final: true, }) }) agent.Tools.Register(messageTool) @@ -315,6 +316,7 @@ func (al *AgentLoop) Run(ctx context.Context) error { Channel: msg.Channel, ChatID: msg.ChatID, Content: response, + Final: true, }) logger.InfoCF("agent", "Published outbound response", map[string]any{ diff --git a/pkg/agent/loop_mcp.go b/pkg/agent/loop_mcp.go index 97debbc33..e0840b7d3 100644 --- a/pkg/agent/loop_mcp.go +++ b/pkg/agent/loop_mcp.go @@ -64,7 +64,7 @@ func (al *AgentLoop) ensureMCPInitialized(ctx context.Context) error { return nil } - if al.cfg.Tools.MCP.Servers == nil || len(al.cfg.Tools.MCP.Servers) == 0 { + if len(al.cfg.Tools.MCP.Servers) == 0 { logger.WarnCF("agent", "MCP is enabled but no servers are configured, skipping MCP initialization", nil) return nil } diff --git a/pkg/bus/types.go b/pkg/bus/types.go index 12da3f1dd..f95c9ad09 100644 --- a/pkg/bus/types.go +++ b/pkg/bus/types.go @@ -34,6 +34,7 @@ type OutboundMessage struct { ChatID string `json:"chat_id"` Content string `json:"content"` ReplyToMessageID string `json:"reply_to_message_id,omitempty"` + Final bool `json:"final,omitempty"` } // MediaPart describes a single media attachment to send.