refactor(cache): simplify signature caching by removing sessionID parameter

This commit is contained in:
Luis Pater
2026-01-21 12:38:05 +08:00
parent 88bf4e77ec
commit 65ad5c0c9d
4 changed files with 44 additions and 55 deletions

View File

@@ -36,11 +36,7 @@ func deriveSessionID(rawJSON []byte) string {
}
for _, msg := range messages.Array() {
if msg.Get("role").String() == "user" {
content := msg.Get("content").String()
if content == "" {
// Try to get text from content array
content = msg.Get("content.0.text").String()
}
content := msg.Get("content").Raw
if content != "" {
h := sha256.Sum256([]byte(content))
return hex.EncodeToString(h[:16])
@@ -138,7 +134,7 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _
// Client may send stale or invalid signatures from different sessions
signature := ""
if sessionID != "" && thinkingText != "" {
if cachedSig := cache.GetCachedSignature(modelName, sessionID, thinkingText); cachedSig != "" {
if cachedSig := cache.GetCachedSignature(modelName, thinkingText); cachedSig != "" {
signature = cachedSig
// log.Debugf("Using cached signature for thinking block")
}

View File

@@ -140,7 +140,7 @@ func ConvertAntigravityResponseToClaude(_ context.Context, _ string, originalReq
// log.Debug("Branch: signature_delta")
if params.SessionID != "" && params.CurrentThinkingText.Len() > 0 {
cache.CacheSignature(modelName, params.SessionID, params.CurrentThinkingText.String(), thoughtSignature.String())
cache.CacheSignature(modelName, params.CurrentThinkingText.String(), thoughtSignature.String())
// log.Debugf("Cached signature for thinking block (sessionID=%s, textLen=%d)", params.SessionID, params.CurrentThinkingText.Len())
params.CurrentThinkingText.Reset()
}