diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index 73d8d61..2124754 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -440,7 +440,6 @@ func (al *AgentLoop) GetSessionHistory(sessionKey string) []providers.Message { } func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) (string, error) { - msg.SessionKey = strings.TrimSpace(msg.SessionKey) if msg.SessionKey == "" { msg.SessionKey = "main" } @@ -462,8 +461,8 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) } // Explicit language command: /lang - if strings.HasPrefix(strings.TrimSpace(msg.Content), "/lang") { - parts := strings.Fields(strings.TrimSpace(msg.Content)) + if strings.HasPrefix(msg.Content, "/lang") { + parts := strings.Fields(msg.Content) if len(parts) < 2 { preferred, last := al.sessions.GetLanguagePreferences(msg.SessionKey) if preferred == "" { @@ -696,7 +695,7 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) } } - if strings.TrimSpace(finalContent) == "" { + if finalContent == "" { if hasToolActivity && len(lastToolOutputs) > 0 { finalContent = "我已执行完成,关键信息如下:\n- " + strings.Join(lastToolOutputs, "\n- ") } else { @@ -712,7 +711,6 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) // Keep full content in debug logs if needed, but remove from final output re := regexp.MustCompile(`(?s).*?`) userContent := re.ReplaceAllString(finalContent, "") - userContent = strings.TrimSpace(userContent) if userContent == "" && finalContent != "" { // If only thoughts were present, maybe provide a generic "Done" or keep something? // For now, let's assume thoughts are auxiliary and empty response is okay if tools did work. diff --git a/pkg/channels/manager.go b/pkg/channels/manager.go index c2bec1b..9e1200a 100644 --- a/pkg/channels/manager.go +++ b/pkg/channels/manager.go @@ -9,7 +9,6 @@ package channels import ( "context" "fmt" - "strings" "sync" "sync/atomic" @@ -298,7 +297,7 @@ func (m *Manager) dispatchOutbound(ctx context.Context) { continue } - action := strings.ToLower(strings.TrimSpace(msg.Action)) + action := msg.Action if action == "" { action = "send" }