feat(cache): handle gemini family in signature cache with fallback validator logic

This commit is contained in:
Luis Pater
2026-01-21 10:11:21 +08:00
parent 2e14f787d4
commit 2ce3553612

View File

@@ -119,12 +119,20 @@ func CacheSignature(modelName, sessionID, text, signature string) {
// GetCachedSignature retrieves a cached signature for a given session and text. // GetCachedSignature retrieves a cached signature for a given session and text.
// Returns empty string if not found or expired. // Returns empty string if not found or expired.
func GetCachedSignature(modelName, sessionID, text string) string { func GetCachedSignature(modelName, sessionID, text string) string {
family := GetModelGroup(modelName)
if sessionID == "" || text == "" { if sessionID == "" || text == "" {
if family == "gemini" {
return "skip_thought_signature_validator"
}
return "" return ""
} }
val, ok := signatureCache.Load(fmt.Sprintf("%s#%s", GetModelGroup(modelName), sessionID)) val, ok := signatureCache.Load(fmt.Sprintf("%s#%s", family, sessionID))
if !ok { if !ok {
if family == "gemini" {
return "skip_thought_signature_validator"
}
return "" return ""
} }
sc := val.(*sessionCache) sc := val.(*sessionCache)
@@ -137,11 +145,17 @@ func GetCachedSignature(modelName, sessionID, text string) string {
entry, exists := sc.entries[textHash] entry, exists := sc.entries[textHash]
if !exists { if !exists {
sc.mu.Unlock() sc.mu.Unlock()
if family == "gemini" {
return "skip_thought_signature_validator"
}
return "" return ""
} }
if now.Sub(entry.Timestamp) > SignatureCacheTTL { if now.Sub(entry.Timestamp) > SignatureCacheTTL {
delete(sc.entries, textHash) delete(sc.entries, textHash)
sc.mu.Unlock() sc.mu.Unlock()
if family == "gemini" {
return "skip_thought_signature_validator"
}
return "" return ""
} }