From a87f09bad21ce33c6b38c93028f66d99458116e5 Mon Sep 17 00:00:00 2001 From: Evan Nguyen Date: Sun, 21 Dec 2025 17:50:41 +0700 Subject: [PATCH] feat(antigravity): add session ID generation and mutex for random source --- .../runtime/executor/antigravity_executor.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/runtime/executor/antigravity_executor.go b/internal/runtime/executor/antigravity_executor.go index 1aaf7ba0..afc6d24a 100644 --- a/internal/runtime/executor/antigravity_executor.go +++ b/internal/runtime/executor/antigravity_executor.go @@ -15,6 +15,7 @@ import ( "net/url" "strconv" "strings" + "sync" "time" "github.com/google/uuid" @@ -44,7 +45,10 @@ const ( refreshSkew = 3000 * time.Second ) -var randSource = rand.New(rand.NewSource(time.Now().UnixNano())) +var ( + randSource = rand.New(rand.NewSource(time.Now().UnixNano())) + randSourceMutex sync.Mutex +) // AntigravityExecutor proxies requests to the antigravity upstream. type AntigravityExecutor struct { @@ -1146,8 +1150,9 @@ func antigravityBaseURLFallbackOrder(auth *cliproxyauth.Auth) []string { return []string{base} } return []string{ - antigravityBaseURLProd, antigravityBaseURLDaily, + // antigravityBaseURLAutopush, + antigravityBaseURLProd, } } @@ -1182,6 +1187,7 @@ func geminiToAntigravity(modelName string, payload []byte, projectID string) []b template, _ = sjson.Set(template, "project", generateProjectID()) } template, _ = sjson.Set(template, "requestId", generateRequestID()) + template, _ = sjson.Set(template, "request.sessionId", generateSessionID()) template, _ = sjson.Delete(template, "request.safetySettings") template, _ = sjson.Set(template, "request.toolConfig.functionCallingConfig.mode", "VALIDATED") @@ -1216,11 +1222,20 @@ func generateRequestID() string { return "agent-" + uuid.NewString() } +func generateSessionID() string { + randSourceMutex.Lock() + n := randSource.Int63n(9_000_000_000_000_000_000) + randSourceMutex.Unlock() + return "-" + strconv.FormatInt(n, 10) +} + func generateProjectID() string { adjectives := []string{"useful", "bright", "swift", "calm", "bold"} nouns := []string{"fuze", "wave", "spark", "flow", "core"} + randSourceMutex.Lock() adj := adjectives[randSource.Intn(len(adjectives))] noun := nouns[randSource.Intn(len(nouns))] + randSourceMutex.Unlock() randomPart := strings.ToLower(uuid.NewString())[:5] return adj + "-" + noun + "-" + randomPart }