Refactor AI Agent and AI Config handling across multiple files

- Updated function signatures to accept AI Agent and AI Config as non-pointer types for better clarity and safety.
- Modified instances where AI Agent and AI Config were dereferenced to improve code readability.
- Removed unnecessary nil checks for AI Agent and AI Config, simplifying the logic.
- Adjusted related tests and services to align with the new function signatures.
- Cleaned up code in runtime, skills, and executor packages to ensure consistency in handling AI configurations.
This commit is contained in:
mlogclub
2026-04-17 17:57:01 +08:00
parent 3b062c327c
commit 976b9defde
36 changed files with 102 additions and 282 deletions
@@ -1,41 +0,0 @@
package graphs
import (
"testing"
"cs-agent/internal/models"
)
func TestHandoffGraphBuildReason(t *testing.T) {
graph := NewHandoffGraph(&models.Conversation{ID: 1}, &models.AIAgent{Name: "AI"})
reason, err := graph.buildReason(`{"reason":" 用户需要人工确认 "}`)
if err != nil {
t.Fatalf("buildReason returned error: %v", err)
}
if reason != "用户需要人工确认" {
t.Fatalf("unexpected reason: %q", reason)
}
}
func TestHandoffGraphBuildReasonFallback(t *testing.T) {
graph := NewHandoffGraph(&models.Conversation{ID: 1}, &models.AIAgent{Name: "AI"})
reason, err := graph.buildReason(`{}`)
if err != nil {
t.Fatalf("buildReason returned error: %v", err)
}
if reason != "用户需要转人工支持" {
t.Fatalf("unexpected fallback reason: %q", reason)
}
}
func TestHandoffGraphBuildSuccessReply(t *testing.T) {
graph := NewHandoffGraph(&models.Conversation{ID: 1}, &models.AIAgent{Name: "AI"})
got := graph.buildSuccessReply()
want := "已为你转接人工客服,请稍候。,请稍候。"
if got != want {
t.Fatalf("unexpected success reply: %q", got)
}
}