agent: replace timestamp-based response IDs with UUIDv4

This commit is contained in:
Ollie Agent 2026-08-01 17:22:16 +02:00
parent fb2956f4e4
commit 0395a4a92f
1 changed files with 6 additions and 5 deletions

View File

@ -8,8 +8,6 @@ import (
"os"
"slices"
"strings"
"time"
"strconv"
"ollie/backend"
)
@ -653,9 +651,12 @@ func (s *History) contextDebug() string {
return sb.String()
}
// NewResponseID generates a unique identifier for a single assistant response.
// NewResponseID generates a UUIDv4 for a single assistant response.
func NewResponseID() string {
b := make([]byte, 3)
b := make([]byte, 16)
rand.Read(b) //nolint:errcheck
return "resp_" + strconv.FormatInt(time.Now().UnixNano(), 10) + "_" + fmt.Sprintf("%06x", b)
b[6] = (b[6] & 0x0f) | 0x40 // version 4
b[8] = (b[8] & 0x3f) | 0x80 // variant 10xx
return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x",
b[0:4], b[4:6], b[6:8], b[8:10], b[10:16])
}