feat(translator): enhance session ID derivation with user_id parsing in Claude
This commit is contained in:
Luis Pater
2026-01-20 12:35:40 +08:00
parent 2cbe4a790c
commit 6184c43319

View File

@@ -22,6 +22,14 @@ import (
// deriveSessionID generates a stable session ID from the request.
// Uses the hash of the first user message to identify the conversation.
func deriveSessionID(rawJSON []byte) string {
userIDResult := gjson.GetBytes(rawJSON, "metadata.user_id")
if userIDResult.Exists() {
userID := userIDResult.String()
idx := strings.Index(userID, "session_")
if idx != -1 {
return userID[idx+8:]
}
}
messages := gjson.GetBytes(rawJSON, "messages")
if !messages.IsArray() {
return ""