History

refactor(cache, translator): remove session ID from signature caching and clean up logic

Luis Pater committed 9 months agov6.7.16

Commit ef4508d1 parent f775e462 files · +5 −6Browse files

Unified · Split

2 files
  1. internal/cache/signature_cache.go +4 −4
  2. internal/translator/antigravity/claude/antigravity_claude_response.go +1 −2
internal/cache/signature_cache.go+4−4
@@ -104,9 +104,9 @@ func CacheSignature(modelName, text, signature string) { · 103 unmodified lines
104 return104 return
105 }105 }
106 106
107 sc := getOrCreateSession(fmt.Sprintf("%s#%s", GetModelGroup(modelName), text))107 text = fmt.Sprintf("%s#%s", GetModelGroup(modelName), text)
108 textHash := hashText(text)108 textHash := hashText(text)
109 109 sc := getOrCreateSession(textHash)
110 sc.mu.Lock()110 sc.mu.Lock()
111 defer sc.mu.Unlock()111 defer sc.mu.Unlock()
112 112
@@ -127,8 +127,8 @@ func GetCachedSignature(modelName, text string) string { · 14 unmodified lines
127 }127 }
128 return ""128 return ""
129 }129 }
130 130 text = fmt.Sprintf("%s#%s", GetModelGroup(modelName), text)
131 val, ok := signatureCache.Load(fmt.Sprintf("%s#%s", family, text))131 val, ok := signatureCache.Load(hashText(text))
132 if !ok {132 if !ok {
133 if family == "gemini" {133 if family == "gemini" {
134 return "skip_thought_signature_validator"134 return "skip_thought_signature_validator"
internal/translator/antigravity/claude/antigravity_claude_response.go+1−2
@@ -41,7 +41,6 @@ type Params struct { · 40 unmodified lines
41 HasContent bool // Tracks whether any content (text, thinking, or tool use) has been output41 HasContent bool // Tracks whether any content (text, thinking, or tool use) has been output
42 42
43 // Signature caching support43 // Signature caching support
44 SessionID string // Session ID derived from request for signature caching
45 CurrentThinkingText strings.Builder // Accumulates thinking text for signature caching44 CurrentThinkingText strings.Builder // Accumulates thinking text for signature caching
46}45}
47 46
@@ -138,7 +137,7 @@ func ConvertAntigravityResponseToClaude(_ context.Context, _ string, originalReq · 90 unmodified lines
138 if thoughtSignature := partResult.Get("thoughtSignature"); thoughtSignature.Exists() && thoughtSignature.String() != "" {137 if thoughtSignature := partResult.Get("thoughtSignature"); thoughtSignature.Exists() && thoughtSignature.String() != "" {
139 // log.Debug("Branch: signature_delta")138 // log.Debug("Branch: signature_delta")
140 139
141 if params.SessionID != "" && params.CurrentThinkingText.Len() > 0 {140 if params.CurrentThinkingText.Len() > 0 {
142 cache.CacheSignature(modelName, params.CurrentThinkingText.String(), thoughtSignature.String())141 cache.CacheSignature(modelName, params.CurrentThinkingText.String(), thoughtSignature.String())
143 // log.Debugf("Cached signature for thinking block (sessionID=%s, textLen=%d)", params.SessionID, params.CurrentThinkingText.Len())142 // log.Debugf("Cached signature for thinking block (sessionID=%s, textLen=%d)", params.SessionID, params.CurrentThinkingText.Len())
144 params.CurrentThinkingText.Reset()143 params.CurrentThinkingText.Reset()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t