mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-07 16:47:30 +08:00
normalize-policy: preserve raw casing/spacing in action-content sensitive paths (phase-3)
This commit is contained in:
@@ -440,7 +440,6 @@ func (al *AgentLoop) GetSessionHistory(sessionKey string) []providers.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) (string, error) {
|
func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) (string, error) {
|
||||||
msg.SessionKey = strings.TrimSpace(msg.SessionKey)
|
|
||||||
if msg.SessionKey == "" {
|
if msg.SessionKey == "" {
|
||||||
msg.SessionKey = "main"
|
msg.SessionKey = "main"
|
||||||
}
|
}
|
||||||
@@ -462,8 +461,8 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Explicit language command: /lang <code>
|
// Explicit language command: /lang <code>
|
||||||
if strings.HasPrefix(strings.TrimSpace(msg.Content), "/lang") {
|
if strings.HasPrefix(msg.Content, "/lang") {
|
||||||
parts := strings.Fields(strings.TrimSpace(msg.Content))
|
parts := strings.Fields(msg.Content)
|
||||||
if len(parts) < 2 {
|
if len(parts) < 2 {
|
||||||
preferred, last := al.sessions.GetLanguagePreferences(msg.SessionKey)
|
preferred, last := al.sessions.GetLanguagePreferences(msg.SessionKey)
|
||||||
if preferred == "" {
|
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 {
|
if hasToolActivity && len(lastToolOutputs) > 0 {
|
||||||
finalContent = "我已执行完成,关键信息如下:\n- " + strings.Join(lastToolOutputs, "\n- ")
|
finalContent = "我已执行完成,关键信息如下:\n- " + strings.Join(lastToolOutputs, "\n- ")
|
||||||
} else {
|
} 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
|
// Keep full content in debug logs if needed, but remove from final output
|
||||||
re := regexp.MustCompile(`(?s)<think>.*?</think>`)
|
re := regexp.MustCompile(`(?s)<think>.*?</think>`)
|
||||||
userContent := re.ReplaceAllString(finalContent, "")
|
userContent := re.ReplaceAllString(finalContent, "")
|
||||||
userContent = strings.TrimSpace(userContent)
|
|
||||||
if userContent == "" && finalContent != "" {
|
if userContent == "" && finalContent != "" {
|
||||||
// If only thoughts were present, maybe provide a generic "Done" or keep something?
|
// 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.
|
// For now, let's assume thoughts are auxiliary and empty response is okay if tools did work.
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ package channels
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
@@ -298,7 +297,7 @@ func (m *Manager) dispatchOutbound(ctx context.Context) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
action := strings.ToLower(strings.TrimSpace(msg.Action))
|
action := msg.Action
|
||||||
if action == "" {
|
if action == "" {
|
||||||
action = "send"
|
action = "send"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user