修复(AI客服): 退款操作统一转人工处理
隐藏并拦截退款类业务动作,兼容旧确认流程,确保所有客户类型的退款请求进入人工支持,并补充回归测试。
This commit is contained in:
@@ -561,3 +561,42 @@ func TestExplicitBusinessCommandIsPreparedWithoutCallingModel(t *testing.T) {
|
||||
t.Fatalf("unexpected confirmation prompt: %q", pending.PromptText)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLegacyRefundConfirmationRequiresHuman(t *testing.T) {
|
||||
database, err := gorm.Open(sqlite.Open("file:"+t.Name()+"?mode=memory&cache=shared"), &gorm.Config{
|
||||
NamingStrategy: schema.NamingStrategy{TablePrefix: "t_", SingularTable: true},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := database.AutoMigrate(&models.ConversationInterrupt{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sqls.SetDB(database)
|
||||
data, _ := json.Marshal(pendingBusinessAction{ToolCode: "business/mall_apply_after_sale", PromptText: "确认退款吗?"})
|
||||
if err := database.Create(&models.ConversationInterrupt{
|
||||
ConversationID: 7, CheckPointID: "legacy-refund", RequestData: string(data), Status: "pending",
|
||||
}).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, reply := range []string{"确认", "确定", "继续", "取消"} {
|
||||
t.Run(reply, func(t *testing.T) {
|
||||
result, err := NewAgentLoopEngine().Resume(context.Background(), ResumeInput{
|
||||
Conversation: models.Conversation{ID: 7, CustomerType: "mall_user"},
|
||||
CheckPointID: "legacy-refund", ResumeData: map[string]string{"business_action_confirmation": reply},
|
||||
})
|
||||
if err != nil || result == nil {
|
||||
t.Fatalf("resume result=%#v err=%v", result, err)
|
||||
}
|
||||
if reply == "取消" {
|
||||
if result.Status != "cancelled" {
|
||||
t.Fatalf("cancellation rejected: %#v", result)
|
||||
}
|
||||
return
|
||||
}
|
||||
if result.Status != "failed" || result.ReplyText != svc.RefundHumanSupportMessage || result.Interrupted || result.ToolCallCount != 0 {
|
||||
t.Fatalf("legacy refund confirmation not blocked: %#v", result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user