fix(ai): prevent customer iccid disclosure

This commit is contained in:
t
2026-08-30 19:52:45 +08:00
parent c39094156c
commit 2994cd5b2c
7 changed files with 122 additions and 5 deletions
@@ -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 != "" {