fix(ai): prevent customer iccid disclosure
This commit is contained in:
@@ -279,12 +279,13 @@ func (e *AgentLoopEngine) buildUserPrompt(req RunInput) (string, int) {
|
||||
if role == "" {
|
||||
continue
|
||||
}
|
||||
lines = append(lines, role+": "+utils.BuildRuntimeMessageText(item.MessageType, item.Content))
|
||||
text := utils.BuildRuntimeMessageText(item.MessageType, item.Content)
|
||||
lines = append(lines, role+": "+aitooling.RedactRestrictedICCID(text))
|
||||
}
|
||||
if len(lines) > limit {
|
||||
lines = lines[len(lines)-limit:]
|
||||
}
|
||||
current := strings.TrimSpace(req.UserMessage.Content)
|
||||
current := aitooling.RedactRestrictedICCID(strings.TrimSpace(req.UserMessage.Content))
|
||||
customerContext := buildAgentLoopCustomerContext(req.Conversation)
|
||||
if len(lines) == 0 && customerContext == "" {
|
||||
return current, 0
|
||||
@@ -316,7 +317,7 @@ func excludeAgentLoopHistoryMessage(message models.Message) bool {
|
||||
|
||||
func buildAgentLoopCustomerContext(conversation models.Conversation) string {
|
||||
parts := make([]string, 0, 4)
|
||||
if name := strings.TrimSpace(conversation.CustomerName); name != "" {
|
||||
if name := strings.TrimSpace(conversation.CustomerName); name != "" && !aitooling.ContainsRestrictedICCID(name) {
|
||||
parts = append(parts, "Customer: "+name)
|
||||
}
|
||||
if segment := customerAfterSalesSegmentName(conversation.CustomerType); segment != "" {
|
||||
|
||||
Reference in New Issue
Block a user